Giter Site home page Giter Site logo

Tidy up typefaces about homoglypher HOT 2 CLOSED

bbkr avatar bbkr commented on September 23, 2024
Tidy up typefaces

from homoglypher.

Comments (2)

bbkr avatar bbkr commented on September 23, 2024

Oh yes, mathematical and letterlike spaces have extremely rare overlaps:

SCRIPT CAPITAL P
MATHEMATICAL SCRIPT CAPITAL P

from homoglypher.

bbkr avatar bbkr commented on September 23, 2024

Phew... quick-and-dirty helper script:

my %typefaces;

my %ascii = (
    'A' => 'A',
    'B' => 'B',
    'C' => 'C',
    'D' => 'D',
    'E' => 'E',
    'F' => 'F',
    'G' => 'G',
    'H' => 'H',
    'I' => 'I',
    'J' => 'J',
    'K' => 'K',
    'L' => 'L',
    'M' => 'M',
    'N' => 'N',
    'O' => 'O',
    'P' => 'P',
    'Q' => 'Q',
    'R' => 'R',
    'S' => 'S',
    'T' => 'T',
    'U' => 'U',
    'V' => 'V',
    'W' => 'W',
    'X' => 'X',
    'Y' => 'Y',
    'Z' => 'Z',
    'ZERO' => 0,
    'ONE' => 1,
    'TWO' => 2,
    'THREE' => 3,
    'FOUR' => 4,
    'FIVE' => 5,
    'SIX' => 6,
    'SEVEN' => 7,
    'EIGHT' => 8,
    'NINE' => 9
);

for (1..0x10FFFF).map( *.uniname ) {

    my @props = .split: ' ';

    # letter or digit name must be last
    next unless %ascii{ @props.tail }:exists;

    # filter out typeface modifiers like MODIFIER LETTER SMALL SCRIPT G
    next if @props.grep: 'MODIFIER';

    # filter out latin versions like LATIN SMALL LETTER SCRIPT G
    next if @props.grep: 'LATIN';

    # filter out shapes like BALLOT BOX WITH BOLD SCRIPT X
    next if @props.grep: 'BOX' | 'DINGBAT' | 'CIRCLED' | 'ARROW';

    # filter out old versions like OLD ITALIC NUMERAL ONE
    next if @props.grep: 'OLD';

    # filter out dotless forms like MATHEMATICAL ITALIC SMALL DOTLESS I
    next if @props.grep: 'DOTLESS';

    # filter out turned forms like TURNED SANS-SERIF Q
    next if @props.grep: 'TURNED' | 'REVERSED';

    # all typefaces
    next unless @props.grep: 'SCRIPT' | 'FULLWIDTH' | 'MONOSPACE' | 'BOLD' | 'ITALIC' | 'SANS-SERIF' | 'FRAKTUR' | 'DOUBLE-STRUCK' | 'BALLOT' | 'OBLIQUE' | 'HEAVY';

    my @path = @props;

    # always looked up character
    my $char = %ascii{ @path.pop };

    my $type = @path.pop if @path.tail eq 'CAPITAL' | 'UPPER'| 'LOWER' | 'SMALL' | 'DIGIT';
    $char .= lc if defined $type and $type eq 'LOWER' | 'SMALL';

    # merge mathematical into consistent blocks
    @path.shift if @path.head eq 'MATHEMATICAL';

    # remove hyphen from property names because it will be used to join properties
    my $path = @path.map( { .subst( '-' ) } ).join( '-' ).lc;

    ( %typefaces{ $path }{ $char } //= [] ).push: .uniparse;

}

for %typefaces.keys.sort -> $path {

    my %values = %typefaces{ $path };

    say 'our %' ~ $path ~ ' = (';

    for (0..9, 'a'..'z', 'A'..'Z').flat {

        next unless %values{ $_ }:exists;
        my @values = %values{ $_ };

        print '    \'', $_, '\' => [ ', @values.map( { '\'' ~ $_ ~ '\'' } ).join( ', ') ,' ],', "\n";
    }

    say ');';
}

say 'our @typeface = (';
for %typefaces.keys.sort -> $path {
    say '%' ~ $path ~ ',';
}
say ');';

from homoglypher.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.