[PATCH 1/2] Added a function to check if specific OS features are available

Lubomir I. Ivanov neolit123 at gmail.com
Sat Oct 20 07:28:45 PDT 2012


On 20 October 2012 08:24, Miika Turkia <miika.turkia at gmail.com> wrote:
> Is there a way to test if the selected font supports the required
> character instead of determining this based on the OS version? Would
> be more universal approach that way.
>

there is a bit of a problem which in the Windows API, but also in Pango.

i've tried the following in divelist.c:set_divelist_font():
-----------
void set_divelist_font(const char *font)
{
	PangoFontDescription *font_desc = pango_font_description_from_string(font);	

	// create context
	PangoContext *c = pango_context_new();
	// set def. font map to context
	pango_context_set_font_map(c, pango_cairo_font_map_get_default());
	// get font from descriptor and context
	PangoFont *f = pango_context_load_font(c, font_desc);
	// get language from locale
	PangoLanguage *lang = pango_language_get_default();
	// get coverage of language for font
	PangoCoverage *cov = pango_font_get_coverage(f, lang);
	// test the two indexes
	if (pango_coverage_get(cov, 0x2605) == PANGO_COVERAGE_NONE ||
	    pango_coverage_get(cov, 0x2606) == PANGO_COVERAGE_NONE)
		g_message("indexes missing");
	else
		g_message("indexes ok");
	g_object_unref(c);

	gtk_widget_modify_font(dive_list.tree_view, font_desc);
	pango_font_description_free(font_desc);
}
--------

this works on linux by fails on windows 7, as it always returns
"indexes missing".
even if the starts are actually displayed for the selected font on the screen.
this is seems to be some sort of a backend issue in
pango_coverage_get() / pango_coverage_get().

and to my knowledge WINAPI is a bit bogus in this regard, so i'm
assuming that pango's backend is using something in these lines.
this means that even if the "Sans" font becomes registered for the
application runtime (which is true), the correct WINAPI method has to
be chosen for
retrieving the stars availabiltiy in windows.c.

i quickly gave a couple of methods a spin:
- GetFontUnicodeRanges() says that a font does not have the star chars
event if it does.
- i can't get GetGlyphIndicesW to work properly with higher 16bit values.


GetGlyphOutline() was reported to work better, but i have not idea how
to use it.

this leaves us with checking the version.

lubomir
--


More information about the subsurface mailing list