#11518: Implement BFont::Blocks
--------------------------------+------------------------------------------
Reporter: dsizzle | Owner: nobody
Type: enhancement | Status: assigned
Priority: normal | Milestone: R1
Component: Kits/Interface | Version: R1/Development
Kit |
Resolution: | Keywords: bfont, blocks, font, unicode
Blocked By: | Blocking: 3651
Has a Patch: 1 | Platform: All
--------------------------------+------------------------------------------
Comment (by dsizzle):
The purpose of the unicode_block_range array is to provide a mapping of
the BeOS constants to the actual Unicode codepoint ranges that they
describe. The existing unicode_block array is simply defining a bitfield
for the blocks, but nowhere is it ever defined what the blocks actually
are. Fontconfig deals in codepoints, so without some sort of mapping
there's no way to know what Unicode block any arbitrary codepoint belongs
to so that BFont::Blocks can set the appropriate bit. For example,
B_LATIN1_SUPPLEMENT_BLOCK is bit 2 in the bitfield, but the only place the
range 0080 - 00FF is mentioned is in the comment...so it has to be defined
somewhere.
The reason the unicode_block_range array only contains the existing blocks
is, as described above, its only purpose is to map the bitfield to ranges.
There is space for more bits in the existing bitfield, so some *could* be
added, but there are more ranges missing from the list than available bits
so it'd be an arbitrary subset (as it is now).
This is why the second addition to the API is a function that allows you
to look up any range of codepoints, so that no other knowledge of Unicode
blocks needs to be hardcoded. It's not as efficient but is future-proof.
I'm not aware of any canonical block list for Unicode, so "block 23"
doesn't necessarily mean anything. If I'm wrong I'd be happy to refactor
to support numerical block lookups.
I hope that all makes sense. If not please let me know.
I made the rest of the stylistic changes described above, except for:
Font.cpp line 848, and 870: why not put the if clause on one line?
- I copied the code (and style) from surrounding functions, so there are
several functions in Font.cpp that use 2 lines for the if clause. Should
I fix all of them? I generally think it's not the best practice to mix in
stylistic changes from code you didn't touch...but I could submit that as
a "code cleanup" patch.
Also for ServerFont.cpp line 514, do you consider it a "multi-line if
statement" when it's one line of code broken up to stay under 80
characters? I left the braces out originally because it's just one
logical line.
--
Ticket URL: <https://dev.haiku-os.org/ticket/11518#comment:34>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.