summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/Font
AgeCommit message (Collapse)Author
2023-03-06Everywhere: Remove NonnullRefPtr.h includesAndreas Kling
2023-03-06LibGfx: Skip old-style emoji lookup for fonts that have color bitmapsAndreas Kling
Ultimately, we should find a way to route all emoji access through the font code, but for now, this patch adds a special case for fonts that are known to have embedded color bitmaps so we can test them.
2023-03-06LibGfx/OpenType: Support one specific type of embedded color bitmapsAndreas Kling
This patch adds support for index format 1 and image format 17. This is enough to get Noto Color Emoji working.
2023-03-06LibGfx: Prepare the paint code for fonts whose glyphs are color bitmapsAndreas Kling
This patch does three things: - Font::has_color_bitmaps() (true if CBLC and CBDT are present) - Glyph now knows when its bitmap comes from a color bitmap font - Painter draws color bitmap glyphs with the appropriate scaling etc
2023-03-06LibGfx/OpenType: Add scaffolding for CBDT and CBLC tablesAndreas Kling
2023-03-06LibGfx/OpenType: Make "glyf" and "loca" tables optionalAndreas Kling
These tables are not guaranteed to be present in all font files.
2023-03-05LibCore+Everywhere: Return an Error from DirIterator::error()Sam Atkins
This also removes DirIterator::error_string(), since the same strerror() string will be included when you print the Error itself. Except in `ls` which is still using fprintf() for now.
2023-03-04LibGfx: Remove Font::glyph_height() virtualAndreas Kling
The override on BitmapFont remains, as that is actually used within the FontEditor program.
2023-03-04LibGfx: Add Font::pixel_size_rounded_up()Andreas Kling
This returns the font's size (distance between ascender and descender) in pixels, rounded up to the nearest integer. This is the number we want to use in a lot of UI code, so let's have a friendly API for it instead of ceil'ing the pixel_size() in a million random places.
2023-03-02LibGfx: Handle multi-code point emoji when computing scaled glyph widthTimothy Flynn
2023-03-01LibGfx+LibUnicode: Support specifying the path to search for emojiTimothy Flynn
Similar to the FontDatabase, this will be needed for Ladybird to find emoji images. We now generate just the file name of emoji image in LibUnicode, and look for that file in the specified path (defaulting to /res/emoji) at runtime.
2023-02-24LibGfx: Remove single-code point Font::glyph_or_emoji_width APITimothy Flynn
All callers are now aware of multi-code point emoji (and must remain so going forward).
2023-02-24LibGfx: Use LibUnicode to filter code points that cannot start an emojiTimothy Flynn
2023-02-24LibGfx: Use the paths to emoji images generated alongside emoji dataTimothy Flynn
Rather than formatting the paths at runtime, as vformat is quite heavy in a profile.
2023-02-22LibGfx: Do not exclude all ASCII code points from emoji lookupsTimothy Flynn
Keycap emoji, for example, begin with ASCII digits. Instead, check the first code point for the Emoji Unicode property. On a profile of scrolling around on the welcome page in the Browser, this raises the runtime percentage of Font::glyph_or_emoji_width from about 0.8% to 1.3%.
2023-02-22LibGfx: Bail early from Emoji::emoji_for_code_point_iterator for ASCIITimothy Flynn
On a profile of scrolling around on the welcome page in the Browser, this drops the runtime percentage of Font::glyph_or_emoji_width from about 70% to 0.8%.
2023-02-22LibGfx: Consider multi-code point glyphs when computing text widthTimothy Flynn
Currently, we compute the width of text one code point at a time. This ignores grapheme clusters (emoji in particular). One effect of this is when highlighting a multi-code point emoji. We will errantly increase the highlight rect to the sum of all code point widths, rather than just the width of the resolved emoji bitmap.
2023-02-22LibGfx: Support computing a font's glyph width with code point iteratorsTimothy Flynn
This allows consideration of multi-code point glyphs.
2023-02-22LibGfx: Implement Emoji::emoji_for_code_point_iterator for UTF-32 viewsTimothy Flynn
2023-02-21LibGfx: Fix const-correctness issuesAndreas Kling
2023-02-19LibTextCodec+Everywhere: Port Decoders to new StringsSam Atkins
2023-02-15LibTextCodec+Everywhere: Make TextCodec::decoder_for() take a StringViewSam Atkins
We don't need a full String/DeprecatedString inside this function, so we might as well not force users to create one.
2023-02-13LibCore: Remove `Stream.h`Tim Schumacher
2023-02-13LibCore: Move Stream-based file into the `Core` namespaceTim Schumacher
2023-02-13LibCore: Rename `File` to `DeprecatedFile`Tim Schumacher
As usual, this removes many unused includes and moves used includes further down the chain.
2023-02-11LibGfx: Introduce with_size method for FontAliaksandr Kalenik
2023-02-08Everywhere: Use ReadonlySpan<T> instead of Span<T const>MacDue
2023-02-05LibGfx: Pass font width to `FontDatabase::get()`Aliaksandr Kalenik
Width need to be passed to `FontDatabase::get()` to resolve font name unambiguously.
2023-01-31LibGfx: Make glyph ID lookup faster with a cacheAndreas Kling
This patch adds a "GlyphPage" cache which stores the mapping between code points and glyph IDs in a segmented table of "pages". This makes Font::glyph_id_for_code_point() significantly faster by not reparsing the font tables every time you call it. In the future, we can add more information to GlyphPage (such as horizontal metrics for each glyph) to further reduce time spent in text layout and painting.
2023-01-29AK: Deprecate the old `AK::Stream`Tim Schumacher
This also removes a few cases where the respective header wasn't actually required to be included.
2023-01-28AK: Remove `try_` prefix from FixedArray creation functionsLinus Groh
2023-01-27LibGfx: Remove declarations for non-existent methodsSam Atkins
2023-01-27LibGfx: Make OTF prefer Cmap tables of the Windows platform againJulian Offenhäuser
As the different Cmap encoding records are guaranteed to be sorted by their platform ID, we would previously prefer the Macintosh platform because of its lower ID value. However, this platform is split up into a lot of encoding formats for different languages, and usually only English is included. This meant that we could not handle most unicode characters anymore. The Windows platform now takes precedence again, as it can handle arbitrary code points in its supported encodings. This solution is still far from perfect, but it makes this regression disappear for now.
2023-01-26LibGfx: Remove `try_` prefix from bitmap creation functionsTim Schumacher
Those don't have any non-try counterpart, so we might as well just omit it.
2023-01-24LibGfx: Cache font pixel metrics in ScaledFontAndreas Kling
Instead of recomputing the pixel metrics over and over, we can just cache them with the font and avoid a bunch of expensive computation.
2023-01-20LibGfx: Use `Core::Stream` to write bitmap fontsTim Schumacher
2023-01-12LibGfx: Provide accessors to instruction data to OpenType::FontMacDue
These probably won't need to stick around forever, but will be helpful for creating some debug utilities.
2023-01-12LibGfx: Parse the TTF fpgm and prep tablesMacDue
These contain the font and CVT programs respectively.
2023-01-12LibGfx: Add OpenType opcodes and helpers to parse instruction streamsMacDue
This defines all the OpenType opcodes/instructions from the specification: https://learn.microsoft.com/en-us/typography/opentype/spec/tt_instructions Each instructions has mnemonic and a range of possible opcodes (as some of the bits are pretty much immediate value flags). There's a little helper Instruction struct for accessing the flags and any associated data (in the case of PUSH instructions). Then the InstructionStream provides a way of iterating over all the instructions in some bytes.
2023-01-09AK+Everywhere: Rename FlyString to DeprecatedFlyStringTimothy Flynn
DeprecatedFlyString relies heavily on DeprecatedString's StringImpl, so let's rename it to A) match the name of DeprecatedString, B) write a new FlyString class that is tied to String.
2023-01-09LibGfx: Implement TrimmedTable mappings for CmapsJulian Offenhäuser
2023-01-09LibGfx: Implement ByteEncoding mappings for CmapsJulian Offenhäuser
2023-01-09LibGfx: Select a valid TTF cmap subtable for the Macintosh platformJulian Offenhäuser
While this subtable ID is supposed to be deprecated, it is used heavily in PDF files. It supports mapping one or two-byte values, with quite a large list of encodings to tell you which one to expect. For our use case, we ignore this encoding ID and just pick the first subtable with this platform ID. Unsupported encodings will get caught by Subtable::glyph_id_for_code_point() anyway.
2023-01-06LibGfx: Make BitmapFont's line gap be Gfx::Painter::LINE_SPACINGAndreas Kling
This is the closest thing we have to the OpenType line gap metrics. Using it here will allow us to unify more of the text painting logic.
2023-01-06LibGfx: Make ScaledFont::glyph_height() return the pixel heightAndreas Kling
This was returning the point height which didn't match BitmapFont and led to bogus line heights in GUI::TextEditor.
2023-01-06LibGfx: Remove unused Font::point_size()Andreas Kling
2023-01-06LibGfx: Make Font::preferred_line_height() more correctAndreas Kling
Return a float, and fix a bogus calculation of ascender + descender.
2023-01-06LibGfx: Remove bogus rounding in FontPixelMetrics::line_spacing()Andreas Kling
2023-01-06LibGfx/OpenType: Use typographic metrics when asked to by the OS/2 tableAndreas Kling
2023-01-05LibGfx+LibPDF: Apply subpixel offset in affine transformationMacDue