Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yixuan committed Dec 7, 2013
0 parents commit e68a474
Show file tree
Hide file tree
Showing 28 changed files with 14,032 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
@@ -0,0 +1,2 @@
^.*\.Rproj$
^\.Rproj\.user$
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.Rproj.user
.Rhistory
.RData
19 changes: 19 additions & 0 deletions DESCRIPTION
@@ -0,0 +1,19 @@
Package: showtext
Type: Package
Title: Enable (any) R graphics devices to show text using (almost) any fonts
Version: 0.1
Date: 2013-12-07
Author: Yixuan Qiu and authors/contributors of the
WenQuanYi Micro Hei font. See file AUTHORS for details.
Maintainer: Yixuan Qiu <yixuan.qiu@cos.name>
Description: This package can override text drawing functions of many
R graphics devices (such as png(), pdf(), etc.), so that texts
will be converted to pure curves and thus device independent.
This will be helpful in situations where the device doesn't
(well) support drawing Unicode characters (Chinese characters in
pdf device, for example).
Depends: R2SWF (>= 0.7)
SystemRequirements: zlib, libpng, FreeType
URL: https://github.com/yixuan/showtext
BugReports: https://github.com/yixuan/showtext/issues
License: Apache License (>= 2.0)
1 change: 1 addition & 0 deletions NAMESPACE
@@ -0,0 +1 @@
export(showtext.begin, showtext.end)
5 changes: 5 additions & 0 deletions NEWS
@@ -0,0 +1,5 @@
CHANGES IN showtext VERSION 0.1

NEW FEATURES

o Initial release.
23 changes: 23 additions & 0 deletions R/font.R
@@ -0,0 +1,23 @@
# environment to store several important variables
.pkg.env = new.env();

# use font.add() to add default font
.add.default.font = function()
{
lib.loc = if("showtext" %in% loadedNamespaces())
dirname(getNamespaceInfo("showtext", "path"))
else NULL;

wqy.r = system.file("fonts", "wqy-microhei.ttc",
package = "showtext", lib.loc = lib.loc);

if("R2SWF" %in% loadedNamespaces())
{
font.add("wqy", wqy.r);
} else {
stop("package R2SWF is not loaded");
}

invisible(NULL);
}

18 changes: 18 additions & 0 deletions R/showtext.R
@@ -0,0 +1,18 @@
showtext.begin = function(nseg = 10L)
{
if(dev.cur() == 1) stop("no active graphics device");
if(nseg <= 0) stop("nseg must be positive");
if(nseg > 100) stop("nseg too large");

.pkg.env$.nseg = as.integer(nseg);
.Call("showtextBegin", PACKAGE = "showtext");
invisible(NULL);
}

showtext.end = function()
{
if(dev.cur() == 1) stop("no active graphics device");

.Call("showtextEnd", PACKAGE = "showtext");
invisible(NULL);
}
20 changes: 20 additions & 0 deletions R/zzz.R
@@ -0,0 +1,20 @@
.onLoad <- function(libname, pkgname) {
library.dynam("showtext", pkgname, libname);
.add.default.font();
.pkg.env$.outline.funs = .Call("showtextLoadOutlineFuns",
PACKAGE = "showtext");
.pkg.env$.nseg = 10L;
.pkg.env$.gdd.save = .Call("showtextReturnNullPointer",
PACKAGE = "showtext");
.pkg.env$.dd.save = .Call("showtextLoadDevDesc",
PACKAGE = "showtext");
}

.onUnload <- function(libpath) {
.Call("showtextCleanOutlineFuns", .pkg.env$.outline.funs,
PACKAGE = "showtext");
.Call("showtextCleanDevDesc", .pkg.env$.dd.save,
PACKAGE = "showtext");
library.dynam.unload("showtext", libpath);
}

5 changes: 5 additions & 0 deletions inst/AUTHORS
@@ -0,0 +1,5 @@
The WenQuanYi Micro Hei font included in the fonts/ subdirectory
is maintained by Qianqian Fang, and contributed by many other users.
See fonts/AUTHORS.txt for a detailed contributed list.

Other part of this package is written by Yixuan Qiu.
10 changes: 10 additions & 0 deletions inst/COPYRIGHTS
@@ -0,0 +1,10 @@
showtext includes the WenQuanYi Micro Hei font file, with copyrights:
Digitized data copyright © 2007, Google Corporation.

Copyright © 2008-2009, WenQuanYi Project Board of
Trustees, All rights reserved.

Droid Sans Fallback extension interface
( http://wenq.org/index.cgi?Fontopia(cn) ),
copyright © 2008-2009 mozbug and Qianqian Fang

0 comments on commit e68a474

Please sign in to comment.