Commit Graph

525 Commits

Author SHA1 Message Date
Øyvind Kolås a93fbc682e app,libgimpcolor: drop babl if guards that no longer apply 2024-02-24 18:14:36 +01:00
Jehan 793d6e7dac app: properly initialize property colors.
Our code expects that these GeglColor properties are always non-NULL in various
places, which may lead to crashes.

The property defaults should take care of this, and I am actually unsure why we
need to set it in the init(). Maybe the set_default() method for the GParamSpec
kicks in a bit late, while we have code syncing objects already running. I'm not
sure. It might need to be investigated later. But for now, let's simply make
sure we initialize the objects manually so that it's never NULL.
2024-02-16 17:28:51 +01:00
Idriss Fekir 1437e3fa99 GimpFont: Crash loading XCF with text in an unavailable font 2024-02-16 12:09:58 +00:00
Jehan 57113323e2 Issue #10813: forgotten GimpRGB used on a GeglColor property. 2024-02-12 19:41:13 +01:00
Jehan e992ca3e51 app, libgimp, pdb, plug-ins: GimpText* using GeglColor.
One of the big improvement in this commit is that text layers are now much
better at space accuracy. They were already space-aware, yet rendered as sRGB u8
only before being converted to the image's space. It means that text layers had
the following limitations:

* Any color out of sRGB gamut were trimmed.
* Precision was always 8-bit (even if the image was high-bit depth).

Now GimpTextLayout keeps track of its source space (for RGB and CMYK only, this
won't be as easy when we will support more backend, since Cairo has only RGB
support for image data) and the image TRC (in case it bypasses the color space's
TRB) and it draws within this gamut and space.
It means first that we are not limited to sRGB colors; we will draw text main
color in the full image gamut, with still 2 remaining limitations:

* Unbounded colors are impossible because Pango format (to color text) uses
  hexadecimal (so even with half/float images, you can't draw out-of-gamut text
  unfortunately).
* Main color precision is still 8-bit, yet a tiny bit better than before as we
  at least follow TRC (so we avoid some of the precision loss when converting,
  even though the bit-depth is still the biggest loss).

The outline color on the other hand is drawn through Cairo API entirely, in
float. This means that the outline color will now be without any precision loss.

Note that this depends on CAIRO_FORMAT_RGBA128F which is only available since
Cairo 1.17.2 which is not in Debian bookworm (our current baseline for GIMP
3.0). It means that the old precision will still happen with older Cairo
version, as determined by #if code at compilation.
2024-02-11 23:28:02 +01:00
Jehan dbbcfb16d5 app, libgimp*, pdb, plug-ins: GimpContext is now using only GeglColor.
- app: gimp_context_get_(foreground|background)() are now returning a GeglColor.
- libgimp: PDB functions named similarly in libgimp are returning a newly
  allocated GeglColor too.
- A few other PDB functions (the ones using these functions) were updated and
  their signature changed to use GeglColor too, when relevant. Plug-ins which
  use any of the changed libgimp functions were fixed.
- GimpContext: signals "(foreground|background)-changed" are now passing a
  GeglColor.
- libgimpconfig: new macro GIMP_CONFIG_PROP_COLOR using gegl_param_spec_color().
- GimpContext: properties "foreground" and "background" are now GeglParamColor
  properties.
- app: All code interacting with GimpContext objects were updated to receive a
  GeglColor (that they may still convert, or no, to GimpRGB for now).
- app: gimp_prop_gegl_color_button_new() was added as an alternative to
  gimp_prop_color_button_new() when the property is a GeglParamColor. Eventually
  the former should replace completely the latter.
- libgimpwidgets: gimp_prop_color_area_new() now works on GeglParamColor
  properties only.
- libgimp: gimp_procedure_dialog_get_widget() will generate a GimpColorArea for
  GeglTypeParamColor arguments.
2024-02-11 23:28:02 +01:00
Idriss Fekir e8ad8af0f7 Fix fonts when exporting to pdf 2023-12-08 11:09:22 +00:00
Idriss Fekir b503a3dc1d Fix bug when font is from a .ttc file
When loading an xcf file, if a a font has already
been used, its file's hash is compared against the hashes
from the xcf file (to speedup loading), but if the font is from a .ttc file (a font
collection), then all fonts from that file will have the same file
hash, so the wrong font might be selected. a simple solution is to not
use the hash except as a last resort if every other field is identical.
2023-10-27 15:48:58 +00:00
Idriss Fekir 68aadf4a27 Issue #9979:bold and italic broken 2023-10-04 12:01:06 +00:00
Jehan adce3179d4 app, libgimp, pdb: further fix gimp_text_get_extents_font() and improve…
… description.

- The returned value as width/height/etc. of the glyph extents (or bounding
  box), not "of the font" (which doesn't mean much).
- Adding some definition for ascent and descent. This text is straight out
  copied from Pango documentation comments in pango/pango-types.h.
- I don't see why we were negating the descent value. Let's keep the value sign
  as defined in Pango.
2023-10-02 21:30:20 +02:00
Jehan a898641cd1 app: fix return type.
Fixes:

> warning: returning ‘void *’ from a function with return type ‘gboolean’
2023-10-02 20:56:19 +02:00
Jehan 24a85eebd6 Issue #9987: text related functions crash using string for font name.
- Fonctions were renamed: s/gimp_text_fontname/gimp_text_font/ and
  s/gimp_text_get_extents_fontname/gimp_text_get_extents_font/
- The size_type arguments were removed. Even in 2.10, this argument was marked
  as "dead" and ignored. It was only kept for API compatibility.
- The font name (string) was replaced by a GimpFont argument.

gimp_text_font() is easily tested in the Python console with:

> Gimp.text_font(Gimp.list_images()[0], None, 10, 40, "Hello World!", 1.0, True, 100, Gimp.context_get_font())

And gimp_text_get_extents_font() with:

> Gimp.text_get_extents_font("Hello World!", 100, Gimp.context_get_font())
2023-10-02 20:49:53 +02:00
Jehan 12d8401d65 app: better handling of failure of gimp_scanner_parse_string().
This fixes 2 issues:

1. gimp_scanner_parse_string() may fail, which here would indicate broken input.
   If it does, the string variable would not be set, so we need to initialize it
   to NULL, otherwise freeing it could crash GIMP.
2. The variables set by gimp_scanner_parse_string() must be freed.
2023-09-22 15:27:59 +02:00
Jehan ae38b433f8 app: improve robustness of font detection algorithm, allowing for future fields.
While I was testing some fonts I had on my system which were named exactly the
same, I also realized that all their fields were identical (among the ones we
store at least), except for the hash obviously. While the hash is great to
differentiate fonts when we use exactly the same files, there are various
reasons where one could have the right font installed with a different hash
(e.g. a simple reason could be if it was stored in different font formats).

So I'm thinking that maybe we'll want to add more fields in the future (if there
are any more fields allowing to better discriminate among some fonts named
similarly). This commit will allow this version of GIMP to still work when
loading the future serialized fonts with new and unknown fields. The unknown
fields will be ignored but at least it will still do its best to find fonts with
the known fields. Therefore we won't have to bump the XCF format version if we
only add new fields.

Similarly this allows to add the fields in-between, reorder existing fields or
even remove some in the future if we realize something is really unneeded. It's
less a big deal than the ability to add new fields without bumping XCF version
though.
2023-09-22 15:16:52 +02:00
Jehan 6c40f10377 app: improve the double loops to deserialize GimpFont.
Rather than looping fully over the full list of fonts once more, and
re-computing a second time the same font similarity score (with the risk of
messing up the copy-paste), let's just store the indexes of "most similar" fonts
in the first loop, then only query and check the hash for these.
2023-09-22 14:09:00 +02:00
Jehan 231ca0c505 Issue #9994: do not call g_file_info_get_is_hidden() (and others) directly.
This is not the main reason for the specific output in #9994. These ones are
more probably because of similar usage in GTK (which updated its own calls to
g_file_info_get_is_hidden|backup() in version 3.24.38). But we should likely
also update the various calls we have to use the generic
g_file_info_get_attribute_*() variants.

To be fair, it is unclear to me when we can be sure that an attribute is set.
For instance, when we call g_file_enumerate_children() or g_file_query_info()
with specific attributes, docs say that it is still possible for these
attributes to not be set. So I assume it means we should never use direct
accessor functions.

The only exception is that I didn't remove usage of g_file_info_get_name(),
since its docs says:

> * Gets a display name for a file. This is guaranteed to always be set.

Even though it also says just after:

> * It is an error to call this if the #GFileInfo does not contain
> * %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME.

Which is very contradictory. But assuming that this error warning was
over-zealous documentation, I kept the direct accessors since they are supposed
to be slightly more optimized (still according to in-code documentation) so
let's priorize them when we know they are set for sure.
2023-09-19 15:34:48 +02:00
Jehan e832b73e55 app: fix a few bug in text markup (de)serialization.
- g_str_equal() doesn't have the proper signature for g_slist_find_custom() so
  current code was never processing multiple subfonts in a markup layer text.
- Escape the font name parsed from the XCF. For old XCF format, it could contain
  forbidden characters. And even for new XCF files (with fonts names generated
  such as 'font123' so there should be no escapable characters), we should not
  trust that the XCF/parasite contents is correct. It can be wrong for various
  reasons.
- Search for ' font="%s"', otherwise the search-and-replace might catch other
  XML attributes. For instance we don't want the font "ultrabold" to match
  weight="ultrabold".
- The backward compatibility code didn't have code to stop 2 font name
  replacements to chain up, i.e. if a real world font was named "gimpfont123"
  and another "gimpfont321" and if our replacement code were to change
  "gimpfont123" to "gimpfont321" then "gimpfont321" to something else. In the
  end, we'd have only a single font. I am fixing it by replacing " font=" to
  " gimpfont=" then only correcting the attribute name at the end. This
  intermediate attribute name acts as a "done" flag.
2023-09-12 14:23:40 +00:00
Jehan ed4c50ce2e app, libgimpconfig: make the code more robust to random text.
There are 3 fixes here:

1. First, searching for "\"GimpFont\"" to determine whether or not this is a new
   format text parasite is not enough, because this string can be found in a
   text layer with "GimpFont" only as contents. It will serialize as:

   > (text "GimpFont")

   Instead search for "(font \"GimpFont\"" which cannot be created as part of
   the text contents because of the unprotected double quotes).

2. We must verify that strstr() did not return NULL when searching for markup
   delimiters. It may happen if the parasite contents is invalid (we must always
   assume it can be, since it's user data).

3. When deserialization of a text from parasite fails (e.g. because parasite
   doesn't actually exist or its format is wrong), still make sure the GimpText
   has a font (setting the standard one before deserializing). Otherwise GIMP
   crashes down the line.

   For this, I also had to fix gimp_config_deserialize_object(): the object type
   name must be parsed even if an object was already set in a GObject property.
2023-09-12 14:23:40 +00:00
Jehan 6d5aaa995f app: new storage format for the text layer parasite implies XCF version bump.
The new parasite format cannot be loaded by old versions of GIMP. This means we
must bump the XCF version (even though technically we didn't really touch the
XCF format itself because text layers are stored in a hackish way, yet text
layers are just too important nowadays to not care).

Nevertheless if an old XCF with text layers was loaded and the text layers left
untouched, the old parasite will be saved back as-is. Therefore no need to bump
the XCF version in this specific case. Only when we created new text layers or
edited existing ones.
2023-09-12 14:23:40 +00:00
Jehan 68167ae01b app: fix counting of similar fonts with largest similarity value and a crash.
Previous code was incrementing the similar_fonts count each time we found a
better candidate. So we ended up computing the hash even when we had only 1
candidate with maximum similarity.

Moreover this commit fixes a crash happening with the "standard font". The
lookup name must always be allocated, even when it's an empty string (otherwise
it crashes at free).

Additionally this commit factorizes the code so that gimp_font_get_hash() takes
care of hash computation instead of duplicating code.

Finally I do some code organization.
2023-09-12 14:23:40 +00:00
Idriss Fekir 899dee5926 (De)Serialize fonts in pango markup 2023-09-12 14:23:40 +00:00
Idriss Fekir 7be3f56f5c Serialize GimpFont and fix loading older xcf files
MR #1011 breaks that because now we have a display name
and a lookup name, so font info is saved in the xcf file,
and when loading, the font which matches these info is used.

This doesn't fix pango markup having the wrong fonts names.
2023-09-12 14:23:40 +00:00
Idriss Fekir a966297498 Port GimpText to GimpFont
In GimpText, The font used to be stored as a string containing its name,
Now, it is stored as a GimpFont object, which makes more sense and makes
operations on fonts easier (such as serialization).
2023-09-12 14:23:40 +00:00
Idriss Fekir 92f133558a gimptextlayout.c: Fix behaviour of RTL text 2023-08-21 13:21:19 +00:00
Stanislav Grinkov 83f6eec57b
app: set the blank font name for the standard font instead of 'Standard'
to fix the issue when 'Standard' can be actual font from the list
or a font which starts with. (ie. Standard Symbols PS)

Fixes: #3104 (GNOME/Gimp tracker)
2023-08-13 12:15:27 +06:00
Idriss Fekir 89ad3a0ab5 Rename every font in fontconfig, not only the broken ones
Some fonts which pango identifies correctly, became broken
after renaming them in fontconfig, so the strategy was to
rename only fonts which pango can't see.

To check if pango got the correct font, the PangoFont
has to be loaded from PangoContext, which is costly.

It Turns out that querying FontConfig with more attributes
fixes this. Hence renaming every font doesn't affect
the fonts pango already sees.
2023-08-05 23:02:59 +00:00
Idriss Fekir 2b73a5996d Remove code path of not using fontconfig
We use fontconfig directly to rename fonts to fix some issues
with Pango (see MR !1011), and fontconfig is present on all
platforms supported by gimp (even on windows, pango is build with
fontconfig as a dependency), so it makes little sense to keep this
code path which is now never used.
2023-08-05 08:58:44 +01:00
Jehan 21a329dae6 app: nearly all GimpFont object now have an associated file.
(except from the aliases "Sans-serif", "Serif" and "Monospace")

The code to get the file path was inspired by code in MR !1011 by Idriss Fekir.

My initial idea was to use FcFreeTypeQueryAll() when adding each font
individually through FcConfigAppFontAddFile() but we were only doing this for
our additional directories (not the system ones) and also before we actually
loaded all the fonts through FontConfig. So this would have required more work
to get right. Though it also means that now the ! USE_FONTCONFIG_DIRECTLY code
path is more broken than ever (as we consider this path information quite
important for plug-ins now).

Additionally to make this work, I got rid of the code making all GimpFont
objects internal data by default, which is nonsense to begin with. Fonts are not
writable by GIMP, sure, yet they are external to GIMP and loaded from a file!

This will be important for an upcoming commit (which is currently in a branch
related to issues #50 and #9250), where we want to implement GimpResource
storage as plug-in settings, because fonts were the only GimpData without a file
and we are using this information to generate a collection identifier.
2023-07-25 23:10:29 +02:00
Jehan 9f9c0b4ea6 app: GimpFontFactory doesn't force anymore unique font names.
Note that there is a `container_obsolete` too in GimpDataFactory and I don't
apply the "unique-name" property to it because I'm unsure what it is.

Furthermore, eventually we'll want all types of data to allow duplicate names
(brushes, patterns or whatnot may come from all sources and may be named the
same by different people). But for now, let's focus on fonts before breaking
other parts of the codebase which we might not look into right now.
2023-07-25 23:10:26 +02:00
Jehan 0226b3ff5e app: only display the number of ignored fonts (and full listing if…
… the GIMP_DEBUG_FONTS environment variable is set.

Turns out nearly a thousand font files get ignored on my installation (and I
don't install much; a lot of them seem to be bitmap fonts (PCF) in a X11
directory). I still want output so that this topic doesn't get forgotten and
hopefully some day, we can do better. But a single line on stderr (and an
environment variable for details) is enough for now.
2023-07-25 21:16:04 +02:00
Idriss Fekir 5972d8d97f Implement support for custom fonts
Remap font names to unique generated names
so that pango sees them.

keep the font name for display and the internal
name for everything else.

* Fonts are still broken When exporting to pdf

* Not sure if xcf files would be usable on other systems
maybe use hash of psname internally instead

* Not sure if plug-ins using text layer work correctly
(do they use internal font name or the actual name?)
2023-07-25 21:16:04 +02:00
Alx Sa ca3c709d56 core: Add color/pattern only fill options
Resolves issue with #8461.
This provides a conditional value for the fill options to only show
a color and pattern, rather than fore/background colors.
Currently only used for the text editor.
2023-06-24 19:42:58 +00:00
Jehan 8ef8ac58aa app: fix crash when loading a XCF containing a text layer with pattern outline.
There was a bug in commit ca6b58e970 which went under the radar. The gimp
variable was not set at creation, so this line was crashing:

> container = gimp_data_factory_get_container (text->gimp->pattern_factory);
2023-06-22 22:23:05 +02:00
Alx Sa ce6f7179ab core: Replace "Solid Colors" with "FG/BG Colors"
Replaces "Solid Colors" option in Fill Path with Foreground/Background
Colors options. This allows users to fill with either, rather than
having to switch the foreground color each time.
GIMP_CONTEXT_PROP_MASK_BACKGROUND was added to the fill and stroke
contexts to allow the background color to be recognized.
In places where Solid Color was used as a default, Foreground Color is
now used instead.
2023-06-22 18:46:14 +00:00
Michael Natterer 26dce72d2c Remove autotools 2023-05-27 00:03:52 +02:00
Michael Natterer 7ada432690 app: big porting of weak pointers to g_set,clear_weak_pointer()
This started as review of weak pointers, but using
g_set_weak_pointer() and g_clear_weak_pointer() is almost always
better, and shorter.
2023-05-22 18:16:09 +02:00
Alx Sa 0aa63806e6 text: Fix xcf load issue caused by MR !751
Loading an .xcf with a patterned outline caused GIMP to crash.
This is because PROP_GIMP was loaded at the end, so it was null when
text->gimp->pattern_factory was called. Moving PROP_GIMP to the
top of the property enum list ensures it's loaded first,
which resolves the issue.
2022-10-13 00:16:44 +00:00
Alx Sa ca6b58e970 text: Add outline options to text editor
This ports Massimo’s code to work in the latest version of GIMP.
It adds new outline-related properties to GimpText and GimpTextOptions.
These are controlled via the Text Tool Editor.
Cairo is currently used to draw the outline around the text.
2022-10-12 22:00:40 +00:00
Jehan ca230cb770 meson: fix warnings of deprecated features.
Now that we bumped our meson requirement, meson is complaining about
several features now deprecated even in the minimum required meson
version:

s/meson.source_root/meson.project_source_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.source_root. use meson.project_source_root() or meson.global_source_root() instead.

s/meson.build_root/meson.project_build_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.build_root. use meson.project_build_root() or meson.global_build_root() instead.

Fixing using path() on xdg_email and python ExternalProgram variables:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead

s/get_pkgconfig_variable *(\([^)]*\))/get_variable(pkgconfig: \1)/ to
fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': dependency.get_pkgconfig_variable. use dependency.get_variable(pkgconfig : ...) instead
2022-08-31 01:29:37 +02:00
Jehan ccbf3c4bb0 app, libgimp*: add various stamp files to CLEANFILES.
Fixes:

> ERROR: files left in build directory after distclean:
2022-08-01 23:34:50 +02:00
Jehan 83e465ec16 app, libgimp*: updating autotools script in sync with meson.
Generated *enums.c now have an additional stamp no-op header include
(see last 2 commits). Sync this change into the autotools generation
scripts to prevent back and forth useless generation of these files each
time we switch from one build system to another.
2022-08-01 20:00:01 +02:00
Jehan 979acaaae2 app, libgimp*: commit the newly generated *enums.c files.
They are nearly the same as initially, except that now they include an
intermediate stamp header which will be generated by the build system.

The only 2 enums which don't need these includes (and are not versioned)
are libgimp/gimpenums.c and libgimpthumb/gimpthumb-enums.c.
2022-08-01 20:00:01 +02:00
Jehan 106f2a061d Issue #8145: meson: generation of '*-enums.c' files.
Our meson build system was not properly building the enums.c file,
because they are versionned.

I did a similar trick as what I did for the pdbgen, which is that I used
a wrapper script around the existing perl script, which sets proper
options and generate a stamp file in the end (which is considered by
meson as the actual custom target, not the C file since it is generated
in the source dir).

The most important part is that the stamp file is a generated header
source (not just a random text file) which is **included** by the
generated C file. This is what will force meson to regenerate the C file
if the header is updated, **then** build using this new version, not use
an outdated versionned version (which would make for hard to diagnose
bugs), through the indirection of the intermediate stamp header.

See #4201.
See also: https://github.com/mesonbuild/meson/issues/10196#issuecomment-1080742592
2022-08-01 19:59:53 +02:00
Nikc b48286009e Issue #2509: Adding support for 'locl' in Text Tool 2022-03-09 17:53:19 +00:00
Stanislav Grinkov 428b944334 Remove unnecessary linking with genmarshal from meson build rules 2021-08-13 18:01:13 +00:00
Jehan 70a9576f27 app, devel-docs, libgimpbase: s/gimp_parasite_name/gimp_parasite_get_name/…
… and s/gimp_parasite_flags/gimp_parasite_get_flags/

It is better to have a consistent API and the fact is that most
getter/setter functions use the _get|set_ naming, but these didn't.

I wondered if this was such a great idea to rename these anyway because
even though we are breaking API in GIMP 3, is it the best idea to rename
when no functional change happened? After discussing with Wormnest, we
still agreed it was still better to go for consistency rather than
regret later (and be stuck with these names for many more years).

Also this fixes these warnings:

> [649/1205] Generating gimp-3.0.vapi with a custom command
> Gimp-3.0.gir:24162.7-24162.56: warning: Field `Gimp.Parasite.flags' conflicts with method of the same name
> Gimp-3.0.gir:24318.7-24318.52: warning: Field `Gimp.Parasite.name' conflicts with method of the same name
2021-04-05 18:36:44 +02:00
luz paz 6457394069 Issue #6446: Typo fixes. 2021-02-24 12:33:03 +01:00
Jehan ee26a39049 app: replace gimp_parasite_data*() with gimp_parasite_get_data(). 2021-01-29 23:52:03 +01:00
Adam Fontenot 00bbeabaf4 Issue #6210: Subpixel font rendering system settings should only…
… apply to GIMP GUI not text layer rendering in image.

Reviewer note: this is the theoretical fix, but it won't work right now
because Cairo explicitly bypasses grayscale antialiasing when system set
subpixel one. Still let's push this first patch, but the issue will be
actually fixed when Cairo will merge my MR too:
https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/114
2021-01-19 13:47:27 +01:00
Jehan b7796b0bfb app: improve sample text logics for CJK fonts.
First of all, "CJK Unified Ideographs" block should not be the highest
priority to determine showing an ideograph. Indeed most fonts for a
Korean and Japanese audience would also contain at least the main
ideographs. So instead, look first for Korean alphabet (Hangul) and
Japanese syllabaries to determine if it's a Korean or Japanese-targetted
font. Only then Chinese.
Also check Korean before Japanese because most of the Korean fonts I saw
actually also include Japanese syllabaries (but not the other way
around).
This way, it will be much easier for CJK graphists to skim through the
font list and detect fonts made for the needed language in a glance.

Also modifying the Korean display text. KIYEOK and SSANGKIYEOK were
obviously chosen because they were the first in the block. But they are
very bad choice. We hesitated with 가 at first, as it is considered the
first in the syllabary form (가나다라 is kind of similar to our ABCD).
But it wouldn't show a form with a second consonant (below) which is a
good stylistic indication. So we hesitated between 한 (han) and 글
(geul, which also means text so it's a nice sample), and finally went
with 한 because of the circle shape in ㅎ (hieut) but also its small
"hat" which has many stylistic variants. So it's quite a good hint of
stylistic choices made by a font designer from just the sample box.

Moreover I switched the block check from "Hangul Jamo" to "Hangul
Syllables" block. "Hangul Jamo" are positional forms of the letters to
dynamically compose syllables (in particular legacy syllables not in use
anymore). Though a feature-full Korean font set would design these, it
is less important than "Hangul Syllables" (pre-composed syllables
design) or "Hangul Compatibility Jamo" (basically the same letters as
"Hangul Jamo" but for standalone usage). Also I actually saw some fonts
made for Korean without "Hangul Syllables" support.

Finally I also added a test for Japanese. I check the Hiragana block
which is most likely the most basic which has to be in any
Japanese-targetted font and use 'あ' (a) as sample text, which is the
first Hiragana syllable and here definitely a good sample text in my
opinion.

I believe that this can still be improved though. Checking only a single
block to determine the probable target language is not necessarily
enough. For instance very complete fonts for Chinese may also design
Korean and Japanese characters, but will also have most CJK blocks and
more ideographs (whereas Japanese/Korean will likely have less). Yet
let's say this is good for now, at least better than before!
2020-11-15 21:55:32 +01:00