History log of /haiku/src/servers/app/ServerFont.h
Revision Date Author Comments
# d0f06357 14-Feb-2024 Jérôme Duval <jerome.duval@gmail.com>

app_server FontManager: load all fonts and named-variants from a file

BFont::LoadFont can now use an index (0-based) and an optional named-instance (1-based)
to select the font variant from a file.
BFont::LoadFont can also use an index when loading from memory.

Change-Id: I0ce3eb6cc77d32cf43847416561eafe3063ca693
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7402
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: Máximo Castañeda <antiswen@yahoo.es>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 6ae6a38e 11-Feb-2023 Máximo Castañeda <antiswen@yahoo.es>

app_server: refactor font managers

Move common add/remove code to the base class and improve encapsulation.
Loading FreeType is the responsibility of the global font manager.
Rename FontManagerBase back to FontManager.

Change-Id: I9396112f01583e19d03011106fd1fa1e37958ee8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6072
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 76b2fd5b 16-Feb-2023 Máximo Castañeda <antiswen@yahoo.es>

app_server: include the manager in the font cache key

App-loaded fonts get the same IDs for different apps, so the cache
entries can be easily overwritten or used for an unexpected font. The
FontManager adds a unique chunk to the string.

Change-Id: I67ea9971784f425370d1aad516af4dae8489c45b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6071
Tested-by: Automation <automation@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 85b82f85 19-Jul-2022 Dale Cieslak <dcieslak@yahoo.com>

BFont: allow loading of user fonts from disk or memory

This patch adds an API call to BFont, called LoadFont, that
takes a string path to a font file. The user fonts are managed
via a new class called AppFontManager that inherits from the base
class FontManagerBase but adds the methods to add and remove user
fonts from disk or memory. There is also a new method called UnloadFont
to remove a user font, but on exit of an app all user fonts should be
automatically cleaned up.

Global/system fonts are managed by the GlobalFontManager, which is
a new class that also inherits from the base class FontManagerBase,
replacing the old "FontManager" class.

A maximum of 128 user fonts may be loaded, and memory fonts
may not exceed 20MB.

There's also an overloaded version of LoadFont that accepts
an area_id and loads the font from memory. A size and offset may
optionally be provided to allow for an area that contains more
than just a font.

Change-Id: I6add42bdf0c0cefc0e2e2a4984fd848c3e7269e5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4790
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 094079b8 04-Jul-2022 Dale Cieslak <dcieslak@yahoo.com>

BFont: Implement BFont::BoundingBox

Extracted as separate patch from CR 4790; implement BFont::BoundingBox
as it was in BeOS. Returns a BRect that encloses any character in a
font, scaled by the font size.

Since the FreeType bbox is only valid for vector outlines, for bitmap
fonts, return a BRect with the dimensions of the bitmap font that is
closest to the font size.

Tested with CharacterMap. Will update CharacterMap to use the bounding
box once this change is landed.

Note that bitmap font rendering doesn't appear to work at all.

Change-ID: I8fc42ca0ddc0c77e04e0216001cd17e086ec7495
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5431
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 60d30785 27-Aug-2020 X512 <danger_mail@list.ru>

app_server memory management fixes: use BReference

Use BReference for more automated reference counting in app_server,
fixing some use-after-free and other problems.

Extracted from https://review.haiku-os.org/c/haiku/+/2695

Change-Id: I141bb248229405896b29feff3338447f7257b0b4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3175
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 8071db32 28-Dec-2018 Michael Lotz <mmlr@mlotz.ch>

app_server: Add char limit to GlyphLayoutEngine::LayoutGlyphs().

Many of the consumers fill in data into preallocated arrays. Some of
them already ignored values past the array size manually, some didn't.

Add a maxChar argument and set it from the incoming array sizes for
the various consumer cases.


# 22ce5525 28-Dec-2018 Michael Lotz <mmlr@mlotz.ch>

app_server: Fix invalid cast of int32 to size_t array.

Make ServerFont::GetBoundingBoxesForStrings() use size_t.


# 9dad3fb4 28-Dec-2018 Michael Lotz <mmlr@mlotz.ch>

app_server: Style and comment cleanup, no functional change.


# 9b6b158b 10-Mar-2016 dsizzle <dcieslak@yahoo.com>

Implementation of BFont::Blocks

BFont::Blocks is now implemented in ServerFont, via a call through the
app_server. It uses fontconfig to iterate through a charset of a font
and stores the defined blocks in a bitmap.

A new API was added, BFont::IncludesBlock, that will allow for arbitrary
testing of a given Unicode block. Since nothing is cached, searching
through an entire charset for a series of Unicode blocks can be quite
slow. In a given block there may be only 1 or 2 characters actually
defined so every character within a block needs to be checked until one
is found, which in a degenerate case will mean the entire block is
checked.

Signed-off-by: Axel Dörfler <axeld@pinc-software.de>


# 91233f88 26-Feb-2014 Stephan Aßmus <superstippi@gmx.de>

Font: Work on support for spacing modes.

* Change default spacing to B_BITMAP_SPACING. The BeBook does not document
what the default spacing is, and I have no BeOS install handy to check.
However, I believe that B_BITMAP_SPACING is what should be the default,
since it gives the best visible result for the common use-case.
In terms of implementation, there is no change, since spacing was ignored
until now and the behavior was that of B_BITMAP_SPACING. This change could
however break BeOS apps which assume B_CHAR_SPACING is the default and don't
set it on new when they need it. Sample code in the BeBook however shows
setting B_CHAR_SPACING on a newly created BFont.
* Implement B_STRING_SPACING to do something sensible. The BeBook documentation
is completely vague in what it is actually supposed to do. Given the
possibilities of FreeType, I am implementing it to enable the use of
kerning. Kerning optimizes the spacing between two glyphs, for example, it
would decrease the spacing between "T" and "e" in the string "Test" for
our default font. Untested.


# 68667bf4 04-Oct-2009 Michael Lotz <mmlr@mlotz.ch>

* Adding a remote desktop interface that operates on app_server drawing
primitives by providing a RemoteDrawingEngine and a RemoteHWInterface.
Not really optimized yet, still a bit WIP.
* Adding corresponding infrastructure like a blocking ring buffer and network
sender/receiver that are attached to the buffers to feed/drain them as well
as a RemoteMessage helper that provides a message based interface.
* Adding target screen concept to request an app to be run on a specific screen.
It's controlled by the TARGET_SCREEN environment variable which is added on
the app side and sent to the app_server.
* Right now only remote target screens are supported, in which case a new
RemoteHWInterface is created that tries to connect to the given host:port.
* Fix shape bounds when drawing, they need to be translated by the pen position
and converted to screen like the points as well. Wasn't visible though as the
bounds weren't used in the normal DrawingEngine.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2637ecd5 20-Jul-2009 Stefano Ceccherini <stefano.ceccherini@gmail.com>

made some methods private. Those weren't used anywhere outside of the class

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e4737a92 31-Dec-2008 Axel Dörfler <axeld@pinc-software.de>

* Added a third hinting mode: monospaced fonts only. This is especially helpful
with low resolution devices like the EeePC - small fonts can look pretty bad
when hinting is turned on, and you still have the advantage of hinting for
text editors and the terminal.
* Added a ServerFont::Hinting() method (that currently only evaluates the
global hinting setting).
* Added a TODO comment on why having global settings is not what we aim for.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28837 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b30a26b 24-May-2008 Stephan Aßmus <superstippi@gmx.de>

Added additional font face flags for "condensed", "light" and "heavy".
Our font has some extra styles and these could be picked up as the
"regular" face by accident, as witnessed by Firefox. Tracked down by
Michael Lotz. Firefox uses the correct font now for it's interface.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25636 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a4de7fa0 27-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Do not trust the client! ServerFont::GetEscapements() now takes a
parameter for the length of the arrays, so that even if the char/byte
counts do not match, no memory is overwritten anymore.
This fixes bug #1862; .canna obviously contains invalid UTF-8
characters, or there is a bug in StyledEdit (or deeper) and it doesn't
call BFont::GetEscapements() correctly.
* Fixed some cases of unchecked allocations in the font handling methods
of ServerApp, added TODOs to all other ones.
* Improved error code when creating a window fails.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24160 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aadc09c6 11-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* fix the mixup of charCount (glyphs) versus bytes. The new font cache
implementation takes the byte count, even though it looks like this is
less efficient when the glyph count is already known (I tested to
optimize it away but it was not faster)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21891 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2222864e 02-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* complete overhaul of the font/glyph caching
* the previous AGG implementation is superfluous
* the new implementation is based on that one, but in a way that allows
read/write locking to the list of cache entries (fonts) as well as
read/write locking to the cached glyphs per individual font cache entry
* new GlyphLayoutEngine.h, which is to be the central place for layouting
glyphs along the baseline.
It handles the locking for getting the font cache entries.
It works by giving it a template class GlyphConsumer which does the
actual work.
* changed AGGTextRenderer to use the new font cache
* changed ServerFont::StringWidth(), and the bounding box stuff to use it
* changed DrawingEngine, it doesn't need the global font lock anymore
* our BFont thought that GetBoundingBoxesAsGlyphs and GetBoundingBoxesAsString
is the same, which of course it isn't, hence the two separate functions...
AsGlyphs just gets the bounding box of each glyph in a string, not treating
the string as an actual word
AsString adds the offset of the glyph in the word to the bounding box
* changed ServerProtocol.h accordingly for the different bounding box meaning


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21797 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5fdc05c1 17-Jul-2007 Stephan Aßmus <superstippi@gmx.de>

* make sure that the 80 chars per line limit is not exceeded


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21638 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 10f6ed94 17-Dec-2006 Stephan Aßmus <superstippi@gmx.de>

* implemented "false bold" for text rendering. It is a new property
of BFont. You can BFont::SetFalseBoldWidth(float) a width on a
BFont object, and it will cause the glyph shapes to be run through
an AGG "contour converter" so that they become thicker or thinner.
IIRC, this is commonly referred to as "false bold". The "width" value
is the distance in pixels that the new glyph outline will be offset
from the original outline.

It would be nice if someone could look at my change to View.h with
regards to the B_FONT_ALL flag.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19547 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 16ed1e1d 18-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Removed headers/private/servers/app - everything is in src/servers/app now.
* Removed DisplaySupport.h, wasn't needed anymore.
* Removed private color set functions from InterfaceDefs.cpp - we might want
something similar, but definitely not like that.
* Minor cleanup, added some missing licenses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16831 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 91233f88a3b4dc392389fad1626c56ed0b3812a0 26-Feb-2014 Stephan Aßmus <superstippi@gmx.de>

Font: Work on support for spacing modes.

* Change default spacing to B_BITMAP_SPACING. The BeBook does not document
what the default spacing is, and I have no BeOS install handy to check.
However, I believe that B_BITMAP_SPACING is what should be the default,
since it gives the best visible result for the common use-case.
In terms of implementation, there is no change, since spacing was ignored
until now and the behavior was that of B_BITMAP_SPACING. This change could
however break BeOS apps which assume B_CHAR_SPACING is the default and don't
set it on new when they need it. Sample code in the BeBook however shows
setting B_CHAR_SPACING on a newly created BFont.
* Implement B_STRING_SPACING to do something sensible. The BeBook documentation
is completely vague in what it is actually supposed to do. Given the
possibilities of FreeType, I am implementing it to enable the use of
kerning. Kerning optimizes the spacing between two glyphs, for example, it
would decrease the spacing between "T" and "e" in the string "Test" for
our default font. Untested.


# 68667bf48a9e29a2d142cb3308b606d80bee3c2d 04-Oct-2009 Michael Lotz <mmlr@mlotz.ch>

* Adding a remote desktop interface that operates on app_server drawing
primitives by providing a RemoteDrawingEngine and a RemoteHWInterface.
Not really optimized yet, still a bit WIP.
* Adding corresponding infrastructure like a blocking ring buffer and network
sender/receiver that are attached to the buffers to feed/drain them as well
as a RemoteMessage helper that provides a message based interface.
* Adding target screen concept to request an app to be run on a specific screen.
It's controlled by the TARGET_SCREEN environment variable which is added on
the app side and sent to the app_server.
* Right now only remote target screens are supported, in which case a new
RemoteHWInterface is created that tries to connect to the given host:port.
* Fix shape bounds when drawing, they need to be translated by the pen position
and converted to screen like the points as well. Wasn't visible though as the
bounds weren't used in the normal DrawingEngine.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2637ecd5473c2291b0cc3a3b119c996a92d6ce13 20-Jul-2009 Stefano Ceccherini <stefano.ceccherini@gmail.com>

made some methods private. Those weren't used anywhere outside of the class

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e4737a9260c764b22b6da57100199428e3bad24d 31-Dec-2008 Axel Dörfler <axeld@pinc-software.de>

* Added a third hinting mode: monospaced fonts only. This is especially helpful
with low resolution devices like the EeePC - small fonts can look pretty bad
when hinting is turned on, and you still have the advantage of hinting for
text editors and the terminal.
* Added a ServerFont::Hinting() method (that currently only evaluates the
global hinting setting).
* Added a TODO comment on why having global settings is not what we aim for.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28837 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b30a26b7ced440833fc4f0369c4ee8d717af99c 24-May-2008 Stephan Aßmus <superstippi@gmx.de>

Added additional font face flags for "condensed", "light" and "heavy".
Our font has some extra styles and these could be picked up as the
"regular" face by accident, as witnessed by Firefox. Tracked down by
Michael Lotz. Firefox uses the correct font now for it's interface.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25636 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a4de7fa0fa41cc3cae689ae24a1245e296272ea5 27-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Do not trust the client! ServerFont::GetEscapements() now takes a
parameter for the length of the arrays, so that even if the char/byte
counts do not match, no memory is overwritten anymore.
This fixes bug #1862; .canna obviously contains invalid UTF-8
characters, or there is a bug in StyledEdit (or deeper) and it doesn't
call BFont::GetEscapements() correctly.
* Fixed some cases of unchecked allocations in the font handling methods
of ServerApp, added TODOs to all other ones.
* Improved error code when creating a window fails.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24160 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aadc09c6651a6b4c522f91d3cc9f137064a66896 11-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* fix the mixup of charCount (glyphs) versus bytes. The new font cache
implementation takes the byte count, even though it looks like this is
less efficient when the glyph count is already known (I tested to
optimize it away but it was not faster)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21891 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2222864eed6bc28cff3d837c98d1509dcbcf38bc 02-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* complete overhaul of the font/glyph caching
* the previous AGG implementation is superfluous
* the new implementation is based on that one, but in a way that allows
read/write locking to the list of cache entries (fonts) as well as
read/write locking to the cached glyphs per individual font cache entry
* new GlyphLayoutEngine.h, which is to be the central place for layouting
glyphs along the baseline.
It handles the locking for getting the font cache entries.
It works by giving it a template class GlyphConsumer which does the
actual work.
* changed AGGTextRenderer to use the new font cache
* changed ServerFont::StringWidth(), and the bounding box stuff to use it
* changed DrawingEngine, it doesn't need the global font lock anymore
* our BFont thought that GetBoundingBoxesAsGlyphs and GetBoundingBoxesAsString
is the same, which of course it isn't, hence the two separate functions...
AsGlyphs just gets the bounding box of each glyph in a string, not treating
the string as an actual word
AsString adds the offset of the glyph in the word to the bounding box
* changed ServerProtocol.h accordingly for the different bounding box meaning


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21797 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5fdc05c105bfceb482c7f123f4f0f0bc25019f13 17-Jul-2007 Stephan Aßmus <superstippi@gmx.de>

* make sure that the 80 chars per line limit is not exceeded


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21638 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 10f6ed940bffa4153ff5511897bcc823b1f2d792 17-Dec-2006 Stephan Aßmus <superstippi@gmx.de>

* implemented "false bold" for text rendering. It is a new property
of BFont. You can BFont::SetFalseBoldWidth(float) a width on a
BFont object, and it will cause the glyph shapes to be run through
an AGG "contour converter" so that they become thicker or thinner.
IIRC, this is commonly referred to as "false bold". The "width" value
is the distance in pixels that the new glyph outline will be offset
from the original outline.

It would be nice if someone could look at my change to View.h with
regards to the B_FONT_ALL flag.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19547 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 16ed1e1d15aac69c945890e5d5990bb41d9f4303 18-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Removed headers/private/servers/app - everything is in src/servers/app now.
* Removed DisplaySupport.h, wasn't needed anymore.
* Removed private color set functions from InterfaceDefs.cpp - we might want
something similar, but definitely not like that.
* Minor cleanup, added some missing licenses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16831 a95241bf-73f2-0310-859d-f6bbb57e9c96