Allow a fallback font for characters above 0xFFFF to be specified. There is no scanning of this range as most fonts don't have any characters here. Symbola is selected if it is installed.

This commit is contained in:
Chris Young 2015-07-06 19:29:16 +01:00
parent 8282f53880
commit c38670ade8
5 changed files with 33 additions and 5 deletions

View File

@ -153,6 +153,8 @@ Additional fall-back fonts can be provided since NetSurf 3.0. These need to go i
NB: Since NetSurf 3.0, NetSurf will scan the provided Unicode fonts, and the rest of the system fonts, on first startup. Setting font_unicode_only:1 will prevent fonts not in the preferred Unicode fonts list from being scanned or used as fallback fonts. If the system fonts or NetSurf's fallback fonts list changes, this cache will need to be re-generated. This can be forced by deleting the font glyph cache (which defaults to Users/user/FontGlyphCache).
Since NetSurf 3.4, Unicode glyphs above 0xFFFF are supported. These are mainly used for Emoji. The option to specify a fallback font for this range is font_surrogate - there is no scanning of system fonts. If @{"Symbola" rxs "address netsurf 'open http://users.teilar.gr/~g1951d/'"} font is installed it will be selected automatically.
@{b}Font sizes@{ub}
The default and minimum font sizes can also be set.

View File

@ -162,7 +162,7 @@ static void ami_font_cleanup(struct MinList *ami_font_list);
static inline ULONG ami_font_unicode_width(const char *string, ULONG length,
const plot_font_style_t *fstyle, ULONG x, ULONG y, bool aa);
static inline int amiga_nsfont_utf16_char_length(uint16 *char1)
static inline int amiga_nsfont_utf16_char_length(const uint16 *char1)
{
if (__builtin_expect(((*char1 < 0xD800) || (0xDBFF < *char1)), 1)) {
return 1;
@ -461,7 +461,12 @@ static struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle
break;
case NSA_UNICODE_FONT:
default:
if(__builtin_expect((amiga_nsfont_utf16_char_length(codepoint) == 2), 0)) {
/* Multi-byte character */
fontname = nsoption_charp(font_surrogate);
} else {
fontname = (char *)ami_font_scan_lookup(codepoint, glypharray);
}
if(fontname == NULL) return NULL;
break;
}
@ -604,6 +609,7 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo
long_char_1 = amiga_nsfont_decode_surrogate(char1);
long_char_2 = amiga_nsfont_decode_surrogate(char2);
/**\todo use OT_GlyphCode_32 so we get an error for old font engines */
if(ESetInfo(AMI_OFONT_ENGINE,
OT_GlyphCode, long_char_1,
@ -690,6 +696,7 @@ static inline int32 ami_font_width_glyph(struct OutlineFont *ofont,
if (*char2 < 0x0020) skip_c2 = true;
long_char_1 = amiga_nsfont_decode_surrogate(char1);
/**\todo use OT_GlyphCode_32 so we get an error for old font engines */
if(ESetInfo(AMI_OFONT_ENGINE,
OT_GlyphCode, long_char_1,

View File

@ -254,7 +254,12 @@ static ULONG ami_font_scan_font(const char *fontname, lwc_string **glypharray)
}
#ifdef __amigaos4__
if(EObtainInfo(AMI_OFONT_ENGINE, OT_UnicodeRanges, &unicoderanges, TAG_END) == 0) {
if(unicoderanges & UCR_SURROGATES) LOG("%s supports UTF-16 surrogates", fontname);
if(unicoderanges & UCR_SURROGATES) {
LOG("%s supports UTF-16 surrogates", fontname);
if (nsoption_charp(font_surrogate) == NULL) {
nsoption_set_charp(font_surrogate, (char *)strdup(fontname));
}
}
EReleaseInfo(AMI_OFONT_ENGINE,
OT_UnicodeRanges, unicoderanges,
TAG_END);

View File

@ -604,13 +604,13 @@ static nserror ami_set_options(struct nsoption_s *defaults)
BPTR lock = 0;
/* Search for some likely candidates */
if((lock = Lock("FONTS:Code2000.font", ACCESS_READ)))
if((lock = Lock("FONTS:Code2000.otag", ACCESS_READ)))
{
UnLock(lock);
nsoption_set_charp(font_unicode,
(char *)strdup("Code2000"));
}
else if((lock = Lock("FONTS:Bitstream Cyberbit.font", ACCESS_READ)))
else if((lock = Lock("FONTS:Bitstream Cyberbit.otag", ACCESS_READ)))
{
UnLock(lock);
nsoption_set_charp(font_unicode,
@ -618,6 +618,19 @@ static nserror ami_set_options(struct nsoption_s *defaults)
}
}
if (nsoption_charp(font_surrogate) == NULL) {
BPTR lock = 0;
/* Search for some likely candidates -
* Ideally we should pick a font during the scan process which announces it
* contains UCR_SURROGATES, but nothing appears to have the tag.
*/
if((lock = Lock("FONTS:Symbola.otag", ACCESS_READ))) {
UnLock(lock);
nsoption_set_charp(font_surrogate,
(char *)strdup("Symbola"));
}
}
if(popupmenu_lib_ok == FALSE)
nsoption_set_bool(context_menu, false);

View File

@ -60,6 +60,7 @@ NSOPTION_BOOL(startup_no_window, false)
NSOPTION_BOOL(close_no_quit, false)
NSOPTION_BOOL(hide_docky_icon, false)
NSOPTION_STRING(font_unicode, NULL)
NSOPTION_STRING(font_surrogate, NULL)
NSOPTION_STRING(font_unicode_file, NULL)
NSOPTION_BOOL(font_unicode_only, false)
NSOPTION_BOOL(font_antialiasing, true)