From: Koichi KAMICHI Date: Fri, 25 Feb 2005 03:57:04 +0000 (+0000) Subject: Added final adjustment function. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=704aa23e5113bba0db4fcd3a33a0e7ed157732a4;p=chise%2Fkage.git Added final adjustment function. --- diff --git a/kagecgi/kage.h b/kagecgi/kage.h index 1be95f9..9809dad 100755 --- a/kagecgi/kage.h +++ b/kagecgi/kage.h @@ -41,6 +41,9 @@ int kShotai; #define FLAG_SURROUND_TOP 4 #define FLAG_SURROUND_BOTTOM 8 +#define DRAW_GLYPH_MODE_NORMAL 0 +#define DRAW_GLYPH_MODE_WITHOUT_DECORATION 1 + typedef struct _kPoint{ double X; double Y; diff --git a/kagecgi/kagecgi.c b/kagecgi/kagecgi.c index bfd494a..d14e1d5 100755 --- a/kagecgi/kagecgi.c +++ b/kagecgi/kagecgi.c @@ -125,13 +125,15 @@ int main(int argc, char *argv[]){ // kg_string_append(test2, test1->str); } + if(test2->len != 0) test2 = finalAdjustment(test2); + if(kType == 0){ //png(image) if(test2->len != 0){ if(kInput != 1){ //0 and 2 test2 = CalcSizes(test2, 1); } DrawBox(); - drawGlyph(test2, 0); + drawGlyph(test2, DRAW_GLYPH_MODE_NORMAL); //output to file filename = kg_string_new(pngFilePath); if(kShotai == kMincho) kg_string_append(filename, "mincho/"); @@ -162,7 +164,7 @@ int main(int argc, char *argv[]){ if(test2->len != 0){ test2 = CalcSizes(test2, 1); kMode = 1; - drawGlyph(test2, 0); + drawGlyph(test2, DRAW_GLYPH_MODE_NORMAL); kg_string_append(kResultText, "\n"); if(type != 1) fprintf(stdout, "Content-type: image/svg-xml\n\n"); fprintf(stdout, "%s", kResultText->str); @@ -176,7 +178,7 @@ int main(int argc, char *argv[]){ if(test2->len != 0){ test2 = CalcSizes(test2, 1); kMode = 2; - drawGlyph(test2, 0); + drawGlyph(test2, DRAW_GLYPH_MODE_NORMAL); kg_string_append(kResultText, "fill\n"); kg_string_append(kResultText, "%%EOF\n"); if(type != 1) fprintf(stdout, "Content-type: application/postscript\n\n"); diff --git a/kagecgi/kagecgi.h b/kagecgi/kagecgi.h index 041b9bf..ed1e55a 100755 --- a/kagecgi/kagecgi.h +++ b/kagecgi/kagecgi.h @@ -45,6 +45,7 @@ void searchAliasData(const KGString *in, KGString *out); void searchCacheData(const KGString *in, KGString *out); void doCombine(const KGString *in, KGString *out); void drawGlyph(const KGString *in, const int mode); +KGString* finalAdjustment(const KGString *in); int isIDS(const KGString *in); void divideInto2(const KGString *in, KGString *partIDS1, KGString *partIDS3); diff --git a/kagecgi/kageeg.c b/kagecgi/kageeg.c index 52944a0..a6e447c 100755 --- a/kagecgi/kageeg.c +++ b/kagecgi/kageeg.c @@ -242,7 +242,7 @@ void drawGlyph(const KGString *in, const int mode){ int *buf; buf = convertStroke(in->str, buf, &j); for(i = 0; i < j; i++){ - if(mode == 0){ //normal + if(mode == DRAW_GLYPH_MODE_NORMAL){ //normal dfDrawFont(buf[i * 11 + 0], buf[i * 11 + 1], buf[i * 11 + 2], @@ -255,7 +255,7 @@ void drawGlyph(const KGString *in, const int mode){ buf[i * 11 + 9], buf[i * 11 + 10]); } - else if(mode == 1){ //without decoration + else if(mode == DRAW_GLYPH_MODE_WITHOUT_DECORATION){ //without decoration dfDrawFont(buf[i * 11 + 0], 0, 0, @@ -272,3 +272,33 @@ void drawGlyph(const KGString *in, const int mode){ free(buf); } +KGString* finalAdjustment(const KGString *in){ + int i, j, k, l, m, n; + int *buf; + KGString *temp; + + n = kShotai; + kShotai = kGothic; + temp = kg_string_new(""); + + DrawBox(); + drawGlyph(in, DRAW_GLYPH_MODE_WITHOUT_DECORATION); + + buf = convertStroke(in->str, buf, &j); + for(i = 0; i < j; i++){ + m = 0; + if(buf[i * 11 + 2] == 13){ + for(k = buf[i * 11 + 5] - kMinWidthT; k < buf[i * 11 + 5] + kMinWidthT; k++){ + for(l = buf[i * 11 + 6] + kWidth * kKakato * 0.5; l < buf[i * 11 + 6] + kWidth * kKakato + pngHeight * 0.1; l++){ + if(0 <= l && l < canvasHeight && 0 <= k && k < canvasHeight && kageCanvas[l][k] != kWhite) m++; + } + } + if(m != 0) buf[i * 11 + 2] = 23; + } + } + convertArray(buf, temp, j, 0); + free(buf); + kShotai = n; + return kg_string_new(temp->str); +} + diff --git a/kagecgi/kagetool.c b/kagecgi/kagetool.c index 046781e..b687bd0 100755 --- a/kagecgi/kagetool.c +++ b/kagecgi/kagetool.c @@ -58,7 +58,7 @@ void PartsWidth(const KGString *in, int *lx, int *rx){ DrawBox(); tempShotai = kShotai; kShotai = kGothic; - drawGlyph(in, 1); + drawGlyph(in, DRAW_GLYPH_MODE_WITHOUT_DECORATION); kShotai = tempShotai; DotsWidth(lx, rx); /* @@ -122,7 +122,7 @@ void PartsHeight(const KGString *in, int *ly, int *ry){ DrawBox(); tempShotai = kShotai; kShotai = kGothic; - drawGlyph(in, 1); + drawGlyph(in, DRAW_GLYPH_MODE_WITHOUT_DECORATION); kShotai = tempShotai; DotsHeight(ly, ry); /* @@ -463,7 +463,7 @@ void CalcOptions(const KGString *in, int *mitsudo, int *flag, double *yoko, doub DrawBox(); tempShotai = kShotai; kShotai = kGothic; - drawGlyph(in, 1); + drawGlyph(in, DRAW_GLYPH_MODE_WITHOUT_DECORATION); kShotai = tempShotai; DotsWidth(&dlx1, &drx1); DotsHeight(&dly1, &dry1);