Giter Club home page Giter Club logo

region-flags's Introduction

CI Build Status Coverage Status PyPI Join the chat at https://gitter.im/fonttools-dev/Lobby

What is this?

fontTools is a library for manipulating fonts, written in Python. The project includes the TTX tool, that can convert TrueType and OpenType fonts to and from an XML text format, which is also called TTX. It supports TrueType, OpenType, AFM and to an extent Type 1 and some Mac-specific formats. The project has an MIT open-source licence.
Among other things this means you can use it free of charge.

User documentation and developer documentation are available at Read the Docs.

Installation

FontTools requires Python 3.8 or later. We try to follow the same schedule of minimum Python version support as NumPy (see NEP 29).

The package is listed in the Python Package Index (PyPI), so you can install it with pip:

pip install fonttools

If you would like to contribute to its development, you can clone the repository from GitHub, install the package in 'editable' mode and modify the source code in place. We recommend creating a virtual environment, using virtualenv or Python 3 venv module.

# download the source code to 'fonttools' folder
git clone https://github.com/fonttools/fonttools.git
cd fonttools

# create new virtual environment called e.g. 'fonttools-venv', or anything you like
python -m virtualenv fonttools-venv

# source the `activate` shell script to enter the environment (Unix-like); to exit, just type `deactivate`
. fonttools-venv/bin/activate

# to activate the virtual environment in Windows `cmd.exe`, do
fonttools-venv\Scripts\activate.bat

# install in 'editable' mode
pip install -e .

Optional Requirements

The fontTools package currently has no (required) external dependencies besides the modules included in the Python Standard Library. However, a few extra dependencies are required by some of its modules, which are needed to unlock optional features. The fonttools PyPI distribution also supports so-called "extras", i.e. a set of keywords that describe a group of additional dependencies, which can be used when installing via pip, or when specifying a requirement. For example:

pip install fonttools[ufo,lxml,woff,unicode]

This command will install fonttools, as well as the optional dependencies that are required to unlock the extra features named "ufo", etc.

  • Lib/fontTools/misc/etree.py

    The module exports a ElementTree-like API for reading/writing XML files, and allows to use as the backend either the built-in xml.etree module or lxml. The latter is preferred whenever present, as it is generally faster and more secure.

    Extra: lxml

  • Lib/fontTools/ufoLib

    Package for reading and writing UFO source files; it requires:

    • fs: (aka pyfilesystem2) filesystem abstraction layer.
    • enum34: backport for the built-in enum module (only required on Python < 3.4).

    Extra: ufo

  • Lib/fontTools/ttLib/woff2.py

    Module to compress/decompress WOFF 2.0 web fonts; it requires:

    • brotli: Python bindings of the Brotli compression library.

    Extra: woff

  • Lib/fontTools/ttLib/sfnt.py

    To better compress WOFF 1.0 web fonts, the following module can be used instead of the built-in zlib library:

    • zopfli: Python bindings of the Zopfli compression library.

    Extra: woff

  • Lib/fontTools/unicode.py

    To display the Unicode character names when dumping the cmap table with ttx we use the unicodedata module in the Standard Library. The version included in there varies between different Python versions. To use the latest available data, you can install:

    • unicodedata2: unicodedata backport for Python 3.x updated to the latest Unicode version 15.0.

    Extra: unicode

  • Lib/fontTools/varLib/interpolatable.py

    Module for finding wrong contour/component order between different masters. It requires one of the following packages in order to solve the so-called "minimum weight perfect matching problem in bipartite graphs", or the Assignment problem:

    • scipy: the Scientific Library for Python, which internally uses NumPy arrays and hence is very fast;
    • munkres: a pure-Python module that implements the Hungarian or Kuhn-Munkres algorithm.

    To plot the results to a PDF or HTML format, you also need to install:

    • pycairo: Python bindings for the Cairo graphics library. Note that wheels are currently only available for Windows, for other platforms see pycairo's installation instructions.

    Extra: interpolatable

  • Lib/fontTools/varLib/plot.py

    Module for visualizing DesignSpaceDocument and resulting VariationModel.

    Extra: plot

  • Lib/fontTools/misc/symfont.py

    Advanced module for symbolic font statistics analysis; it requires:

    • sympy: the Python library for symbolic mathematics.

    Extra: symfont

  • Lib/fontTools/t1Lib.py

    To get the file creator and type of Macintosh PostScript Type 1 fonts on Python 3 you need to install the following module, as the old MacOS module is no longer included in Mac Python:

    • xattr: Python wrapper for extended filesystem attributes (macOS platform only).

    Extra: type1

  • Lib/fontTools/ttLib/removeOverlaps.py

    Simplify TrueType glyphs by merging overlapping contours and components.

    • skia-pathops: Python bindings for the Skia library's PathOps module, performing boolean operations on paths (union, intersection, etc.).

    Extra: pathops

  • Lib/fontTools/pens/cocoaPen.py and Lib/fontTools/pens/quartzPen.py

    Pens for drawing glyphs with Cocoa NSBezierPath or CGPath require:

    • PyObjC: the bridge between Python and the Objective-C runtime (macOS platform only).
  • Lib/fontTools/pens/qtPen.py

    Pen for drawing glyphs with Qt's QPainterPath, requires:

    • PyQt5: Python bindings for the Qt cross platform UI and application toolkit.
  • Lib/fontTools/pens/reportLabPen.py

    Pen to drawing glyphs as PNG images, requires:

    • reportlab: Python toolkit for generating PDFs and graphics.
  • Lib/fontTools/pens/freetypePen.py

    Pen to drawing glyphs with FreeType as raster images, requires:

    • freetype-py: Python binding for the FreeType library.
  • Lib/fontTools/ttLib/tables/otBase.py

    Use the Harfbuzz library to serialize GPOS/GSUB using hb_repack method, requires:

    • uharfbuzz: Streamlined Cython bindings for the harfbuzz shaping engine

    Extra: repacker

How to make a new release

  1. Update NEWS.rst with all the changes since the last release. Write a changelog entry for each PR, with one or two short sentences summarizing it, as well as links to the PR and relevant issues addressed by the PR. Do not put a new title, the next command will do it for you.
  2. Use semantic versioning to decide whether the new release will be a 'major', 'minor' or 'patch' release. It's usually one of the latter two, depending on whether new backward compatible APIs were added, or simply some bugs were fixed.
  3. Run python setup.py release command from the tip of the main branch. By default this bumps the third or 'patch' digit only, unless you pass --major or --minor to bump respectively the first or second digit. This bumps the package version string, extracts the changes since the latest version from NEWS.rst, and uses that text to create an annotated git tag (or a signed git tag if you pass the --sign option and your git and Github account are configured for signing commits using a GPG key). It also commits an additional version bump which opens the main branch for the subsequent developmental cycle
  4. Push both the tag and commit to the upstream repository, by running the command git push --follow-tags. Note: it may push other local tags as well, be careful.
  5. Let the CI build the wheel and source distribution packages and verify both get uploaded to the Python Package Index (PyPI).
  6. [Optional] Go to fonttools Github Releases page and create a new release, copy-pasting the content of the git tag message. This way, the release notes are nicely formatted as markdown, and users watching the repo will get an email notification. One day we shall automate that too.

Acknowledgements

In alphabetical order:

aschmitz, Olivier Berten, Samyak Bhuta, Erik van Blokland, Petr van Blokland, Jelle Bosma, Sascha Brawer, Tom Byrer, Antonio Cavedoni, Frédéric Coiffier, Vincent Connare, David Corbett, Simon Cozens, Dave Crossland, Simon Daniels, Peter Dekkers, Behdad Esfahbod, Behnam Esfahbod, Hannes Famira, Sam Fishman, Matt Fontaine, Takaaki Fuji, Rob Hagemans, Yannis Haralambous, Greg Hitchcock, Jeremie Hornus, Khaled Hosny, John Hudson, Denis Moyogo Jacquerye, Jack Jansen, Tom Kacvinsky, Jens Kutilek, Antoine Leca, Werner Lemberg, Tal Leming, Peter Lofting, Cosimo Lupo, Olli Meier, Masaya Nakamura, Dave Opstad, Laurence Penney, Roozbeh Pournader, Garret Rieger, Read Roberts, Colin Rofls, Guido van Rossum, Just van Rossum, Andreas Seidel, Georg Seifert, Chris Simpkins, Miguel Sousa, Adam Twardoch, Adrien Tétar, Vitaly Volkov, Paul Wise.

Copyrights

Copyright (c) 1999-2004 Just van Rossum, LettError ([email protected])
See LICENSE for the full license.

Copyright (c) 2000 BeOpen.com. All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives. All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved.

Have fun!

region-flags's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

region-flags's Issues

ISO 3166-3 alpha-4 codes

Removed or deprecated ISO alpha-2 codes normally get alpha-4 codes in Part 3 of the standard. This is a way to support flags for “countries” that are no more (but had existed after 1949 or so), because they split up, merged with other countries or just changed their name significantly.

Should they be added?

Private-use codes Q…, X…

XK for Kosovo has been added. It’s being used by CLDR/Unicode, IMF and some others. There are some other private use alpha-2 codes that are (or could be) associated with flags within some implementations of ISO 3166-1. What are the criteria for adding such?

Update list of regions to Unicode

Unicode now defines which regions are emoji flags. According to Mark Davis:


The valid flags used to be less clearly specified, but they are defined in the newest (v2.0) spec, http://unicode.org/reports/tr51/

ED-14. emoji flag sequence — A sequence of two Regional Indicator characters, where the corresponding ASCII characters are valid region sequences as specified by Unicode region subtags in [CLDR].

Those Unicode region subtags are based on BCP47, but have some small changes (including http://unicode.org/emoji/charts/full-emoji-list.html#1f1fd_1f1f0The valid flags used to be less clearly specified, but they are defined in the newest (v2.0) spec, http://unicode.org/reports/tr51/

ED-14. emoji flag sequence — A sequence of two Regional Indicator characters, where the corresponding ASCII characters are valid region sequences as specified by Unicode region subtags in [CLDR].

Those Unicode region subtags are based on BCP47, but have some small changes (including http://unicode.org/emoji/charts/full-emoji-list.html#1f1fd_1f1f0


We should switch to this instead of BCP 47 itself.

WIPO ST.3 codes

ISO 3166/MA won’t assign (non-private) alpha-2 codes that are used by WIPO standard ST.3, cf. my Gist. These are codes for pan-national patent and intellectual property organizations. Most of them don’t have flags. Should they be added anyhow? (I think not.)

Better PNG compression

Consider switching to optipng-zopfli, as well as using pngquant. See usage in noto-emoji for the latter.

Only few reserved country codes missing

I noticed this project contains a bunch of reserved country codes (see the Exceptional reservations section).

This repository contains flags for AC, CP, DG, EA, EU, IC, TA and UN. These are almost all reserved country codes, only a few are missing.

For example, the flag for the UK country code, which is listed on Wikipedia, is not in this repository. The same goes for SU.

For the sake of completeness I think these missing flags should be added.

Add Russian and Belorussian opposition flags #StandWithUkraine

Russia and Belarus are currently totalitarian states where opposition is either driven out of the country, imprisoned, or outright killed. This lack of opposition is mainly to blame for the current war with Ukraine. It would be nice if we could help anti-war and anti-government oppositions by doing a non-disruptive region-flag addition.

The white-blue-white flag has become the symbol of the Russian anti-war protests in 2022. Sadly, there is no such flag yet. Adding new flags to Unicode is impossible (as described by Unicode's Emoji Proposal's Flags section) but, technically, Unicode's territory subdivisions can be used to add a white-blue-white flag without any changes to the Unicode standard itself. Russia's own Novgorod territory subdivision code can be used for this purpose: rungr.

Similarly, the white-red-white flag has become the de-facto symbol of the Belorussian protests in 2020.
In the Belorussian case, the situation is a bit trickier but still manageable: Minsk Region bymi code can be used. Alternatively, Colombia's Atlántico territory subdivision code flag can be added: coatl has a similar flag.

References
"Let's add a Belarusian national flag emoji (change.org)" https://www.change.org/p/unicode-consortium-let-s-add-a-belarusian-national-flag-emoji

Appendix A. Currently used workarounds.
Currently, the Russian opposition uses the following replacements:
🤍💙🤍, ⬜🟦⬜, ⚪🔵⚪, or sometimes ❌.
Similarly, the Belorussian opposition is resorting to the following sequences:
🤍❤️🤍, ⬜🟥⬜, ⚪🔴⚪.

Bower

Thanks for this amazing project - I'd like to use it for my popular International Telephone Input project. I was just wondering if you would consider publishing the project as a Bower package?

Error: invalid tar file when downloading via NPM

Downloading this package via NPM results in the following error:

warn Error on download for github:behdad/region-flags
     Error: invalid tar file
         at Extract.Parse._startEntry (D:\projects\myproject\node_modules\tar\lib\parse.js:149:13)
         at Extract.Parse._process (D:\projects\myproject\node_modules\tar\lib\parse.js:131:12)
         at BlockStream.<anonymous> (D:\projects\myproject\node_modules\tar\lib\parse.js:47:8)
         at emitOne (events.js:96:13)
         at BlockStream.emit (events.js:188:7)
         at BlockStream._emitChunk (D:\projects\myproject\node_modules\block-stream\block-stream.js:145:10)
         at BlockStream.write (D:\projects\myproject\node_modules\block-stream\block-stream.js:45:10)
         at Extract.Parse.write (D:\projects\myproject\node_modules\tar\lib\parse.js:81:23)
         at Gunzip.ondata (_stream_readable.js:555:20)
         at emitOne (events.js:96:13)
         at Gunzip.emit (events.js:188:7)
         at readableAddChunk (_stream_readable.js:176:18)
         at Gunzip.Readable.push (_stream_readable.js:134:10)
         at Gunzip.Transform.push (_stream_transform.js:128:32)
         at Zlib.callback (zlib.js:609:14)

err  Error downloading github:behdad/region-flags.

Have you faced it, too? How to fix it?

Flags of US and UK subregions needed

Unicode is considering adding support for subregional flags.

My guess is the most in-demand are going to be the US states, and the four UK countries.

Spelling it out, it's actually 51 US subregions (including DC).

The list for US is at https://www.iso.org/obp/ui/#iso:code:3166:US (exclude those saying "outlying area", which already have a BCP47 code).

The list for UK is at https://www.iso.org/obp/ui/#iso:code:3166:GB. We only need the three countries and the one province:

GB-ENG: England
GB-NIR: Northern Ireland
GB-WLS: Wales
GB-SCT: Scotland

Add to NPM

Would you be interested in registering region-flags as a package on NPM? It's the most popular package manager for the JavaScript community, and adding region-flags would allow more devs to find and use it! Plus it's super easy.

There are two steps:

  1. You need a package.json file in the root dir, which I can prepare in a pull request
  2. You need to install npm and cd into the region-flags directory and run a couple of commands: npm adduser and follow instructions to create a new user for yourself, then npm publish to add region-flags to the npm index.

Let me know what you think, thanks!

Use sub-directories for sub-regions

Some ISO 3166-2 subregions for US and UK/GB are already included as US-##.{svg,png.html} and UK-###.*, respectively. BCP47 doesn’t care much about those, but UTR51.10+ does.

There are currently 5000ish subregion codes, many of which do not have a flag associated with them. Anyhow, this could easily get unwieldy in the directories if added in the future. Github Web “only” supports 1000 files per folder, if I remember correctly. I therefore suggest to move sub-region flags into sub-directories, i.e. effectively just replace the hyphen - in file names by a slash /.

Symlinks don't work on Windows

Dang apparently Bower (and npm) ignore symlinks because they don't work on Windows.

Is there a way to get all the flags without symlinks?

Overview of missing regions, states, territories, provinces and muncipalities (AR, AU, BQ, ES, FR, GE, NL, PT)

I know including every region ever is impossible, but I still wanted to provide an overview of what is missing.

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.