From: Koichi KAMICHI Date: Fri, 17 Dec 2004 05:51:32 +0000 (+0000) Subject: Make source clean. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=73d35c5574c0c1f66c6c8122ebd58fb5a30a1e96;p=chise%2Fkage.git Make source clean. Add 3-combine method (as temp.). Change condtion for each combine method. --- diff --git a/kagecgi/kage.h b/kagecgi/kage.h index 38a9f9e..9a9dd11 100755 --- a/kagecgi/kage.h +++ b/kagecgi/kage.h @@ -24,6 +24,11 @@ int kShotai; #define kMaxIDSSequenceLength 16 #define kMaxIDCLength 16 #define kMaxStrokeDataLength 256 // over 12(digits per integer with +/- flag) * 11(columns) + 1(line end) + +#define FLAG_FLAT_LEFT 1 +#define FLAG_FLAT_RIGHT 2 +#define FLAG_FLAT_TOP 4 +#define FLAG_FLAT_BOTTOM 8 typedef struct _kPoint{ double X; diff --git a/kagecgi/kagecomb.c b/kagecgi/kagecomb.c index 27d1174..0f4a297 100755 --- a/kagecgi/kagecomb.c +++ b/kagecgi/kagecomb.c @@ -6,111 +6,119 @@ #include "sysdep.h" void combineYoko2(const KGString *parts1, const KGString *parts3, int *result){ - int f, g, h, i, j, k, l; - int flg_boxL, flg_boxR; - int Xside, YsideLa, YsideLb, YsideRa, YsideRb, YheightL, YnanameL, YsmallL; - int pxL, pxR, pyL, pyR; - double prL, prR, pryL, pryR, rL, rR, rTemp; - int lxL, rxL, lxR, rxR; - int dlyL, dryL, dlyR, dryR; - int chk_y1, chk_y2; - int mitsuL, mitsuR; - double yokoL, tateL, yokoR, tateR; + int f, g, h, i, j, k, l; + int flg_boxL, flg_boxR; + int YsideLa, YsideLb, YsideRa, YsideRb, YheightL, YnanameL, YsmallL; + int pxL, pxR, pyL, pyR; + double prL, prR, pryL, pryR, rL, rR, rTemp; + int lxL, rxL, lxR, rxR; + int dlyL, dryL, dlyR, dryR; + int chk_y1, chk_y2; + int mitsuL, mitsuR; + double yokoL, tateL, yokoR, tateR; int *buf, strokes; int tempShotai; //initialize - pxL = 0; - pyL = 0; - prL = 1.0; - pryL = 1.0; - pxR = 0; - pyR = 0; - prR = 1.0; - pryR = 1.0; - - YsideLa = 0; - YsideLb = 0; - YsideRa = 0; - YsideRb = 0; + pxL = 0; + pyL = 0; + prL = 1.0; + pryL = 1.0; + pxR = 0; + pyR = 0; + prR = 1.0; + pryR = 1.0; + + YsideLa = 0; + YsideLb = 0; + YsideRa = 0; + YsideRb = 0; YnanameL = 0; - YheightL = pngWidth * 0.9; + YheightL = pngWidth * 0.9; tempShotai = kShotai; kShotai = kGothic; - CalcOptions(parts1, &mitsuL, &flg_boxL, &yokoL, &tateL); - CalcOptions(parts3, &mitsuR, &flg_boxR, &yokoR, &tateR); + CalcOptions(parts1, &mitsuL, &flg_boxL, &yokoL, &tateL); + CalcOptions(parts3, &mitsuR, &flg_boxR, &yokoR, &tateR); //left parts Y-axis processing #1 - //if its upper and bottom are flat - if(flg_boxL % 8 / 4 != 0) YsideLa++; - if(flg_boxL % 16 / 8 != 0) YsideLb++; - - //if its goes right-up - if(flg_boxL % 1024 / 512 == 0){ - j = 0; - buf = convertStroke(parts1->str, buf, &strokes); - for(i = 0; i < strokes; i++) if(buf[i * 11 + 0] / 10 == 1) j++; - free(buf); - l = 0; - if(j != 0){ - YsideLb++; - YnanameL++; - } + + //if its upper and bottom are flat + if(flg_boxL & FLAG_FLAT_TOP) YsideLa++; + if(flg_boxL & FLAG_FLAT_BOTTOM) YsideLb++; + + //if its goes right-up + j = 0; + buf = convertStroke(parts1->str, buf, &strokes); + for(i = 0; i < strokes; i++){ + if(buf[i * 11 + 0] / 10 == 1){ + j++; + } } - YheightL = YheightL - (YsideLa + YsideLb) * 2 * kWidth; + free(buf); + l = 0; + if(j != 0){ + YsideLb++; + YnanameL++; + } + YheightL = YheightL - (YsideLa + YsideLb) * 2 * kWidth; //left parts Y-axis processing #2 - YsmallL = 0; - if(flg_boxL % 1024 / 512 == 0){ - YsmallL = 1; - if(flg_boxL % 16 / 8 != 0 && flg_boxL % 8 / 4 != 0 && tateL <= 4) YheightL = (double)YheightL * (max(0.65, tateL * 0.22)); - else if(flg_boxL % 16 / 8 != 0 && tateL <= 3) YheightL = (double)YheightL * 0.8; - else if(YnanameL != 0 && flg_boxL % 8 / 4 != 0 && tateL <= 4) YheightL = (double)YheightL * (max(0.65, tateL * 0.22)); - else if(YnanameL != 0 && tateL <= 3) YheightL = (double)YheightL * 0.8; - else YsmallL = 0; + YsmallL = 0; + YsmallL = 1; + if(flg_boxL & FLAG_FLAT_TOP && flg_boxL & FLAG_FLAT_BOTTOM && tateL <= 4){ + YheightL = (double)YheightL * (max(0.65, tateL * 0.22)); + } else if(flg_boxL & FLAG_FLAT_BOTTOM && tateL <= 3){ + YheightL = (double)YheightL * 0.8; + } else if(YnanameL != 0 && flg_boxL & FLAG_FLAT_TOP && tateL <= 4){ + YheightL = (double)YheightL * (max(0.65, tateL * 0.22)); + } else if(YnanameL != 0 && tateL <= 3){ + YheightL = (double)YheightL * 0.8; + } else{ + YsmallL = 0; } //left parts Y-axis processing #3 - DoDrawParts(parts1, pxL, prL, pyL, pryL); - DotsHeight(&dlyL, &dryL); - pryL = (double)YheightL / (dryL - dlyL); - - if(YsmallL != 0){ - if(flg_boxL % 8 / 4 != 0) pyL = kBaseline - (double)pngWidth * 0.9 + 6 * kWidth - dlyL * pryL; - else pyL = kBaseline - (double)pngWidth * 0.9 + 2 * kWidth - dlyL * pryL; - } - else{ - if(flg_boxL % 16 / 8 != 0 || YnanameL != 0) pyL = kBaseline - 2 * kWidth - dryL * pryL; - else pyL = kBaseline - dryL * pryL; - } + DoDrawParts(parts1, pxL, prL, pyL, pryL); + DotsHeight(&dlyL, &dryL); + pryL = (double)YheightL / (dryL - dlyL); + + if(YsmallL != 0){ + if(flg_boxL & FLAG_FLAT_TOP){ + pyL = kBaseline - (double)pngWidth * 0.9 + 6 * kWidth - dlyL * pryL; + } else{ + pyL = kBaseline - (double)pngWidth * 0.9 + 2 * kWidth - dlyL * pryL; + } + } else{ + if(flg_boxL & FLAG_FLAT_BOTTOM || YnanameL != 0){ + pyL = kBaseline - 2 * kWidth - dryL * pryL; + } else{ + pyL = kBaseline - dryL * pryL; + } + } //right parts Y-axis processing #1 - if(flg_boxR % 8 / 4 != 0) YsideRa++; - if(flg_boxR % 16 / 8 != 0) YsideRb++; + if(flg_boxR & FLAG_FLAT_TOP) YsideRa++; + if(flg_boxR & FLAG_FLAT_BOTTOM) YsideRb++; - DoDrawParts(parts3, pxR, prR, pyR, pryR); + DoDrawParts(parts3, pxR, prR, pyR, pryR); DotsHeight(&dlyR, &dryR); - if(flg_boxR % 512 / 256 != 0 && flg_boxR % 1024 / 512 == 0){ - pryR = pngWidth * 0.9 * 0.8 / (dryR - dlyR); - pyR = kBaseline - pngWidth * 0.9 + 6 * kWidth - dlyR * pryR; - } - else{ - pryR = ((double)pngWidth * 0.9 - (YsideRa + YsideRb) * 2 * kWidth) / (dryR - dlyR); - pyR = kBaseline - dryR * pryR; - if(flg_boxR % 16 / 8 != 0) pyR = pyR - 2 * kWidth; + pryR = ((double)pngWidth * 0.9 - (YsideRa + YsideRb) * 2 * kWidth) / (dryR - dlyR); + pyR = kBaseline - dryR * pryR; + if(flg_boxR & FLAG_FLAT_BOTTOM){ + pyR = pyR - 2 * kWidth; } //calculate ratio rL = yokoL; rR = yokoR; - if(flg_boxL % 2 / 1 != 0) rL = rL * 0.7; - if(flg_boxL % 4 / 2 != 0) rL = rL * 0.7; - if(flg_boxR % 2 / 1 != 0) rR = rR * 0.7; - if(flg_boxR % 4 / 2 != 0) rR = rR * 0.7; + if(flg_boxL & FLAG_FLAT_LEFT) rL = rL * 0.7; + if(flg_boxL & FLAG_FLAT_RIGHT) rL = rL * 0.7; + if(flg_boxR & FLAG_FLAT_LEFT) rR = rR * 0.7; + if(flg_boxR & FLAG_FLAT_RIGHT) rR = rR * 0.7; rL = pow(rL, 0.6); rR = pow(rR, 0.6); @@ -121,37 +129,19 @@ void combineYoko2(const KGString *parts1, const KGString *parts3, int *result){ rL = rL / rTemp; rR = rR / rTemp; -// if(r < 0.3) r = 0.3; -// else if(r > 0.7) r = 0.7; - - prL = rL; - prR = rR; + prL = rL; + prR = rR; //calculate width of each parts #1 - Xside = 0; - if(flg_boxL % 2 / 1 != 0) Xside++; - if(flg_boxR % 4 / 2 != 0) Xside++; - -// DrawBox(); -// drawGlyph(parts1, 1); -// DotsWidth(&lxL, &rxL); -// DrawBox(); -// drawGlyph(parts3, 1); -// DotsWidth(&lxR, &rxR); - PartsWidth(parts1, &lxL, &rxL); - PartsWidth(parts3, &lxR, &rxR); - g = 0; + PartsWidth(parts1, &lxL, &rxL); + PartsWidth(parts3, &lxR, &rxR); + g = 0; //calculate width of each parts #2 -//1 pxL = kWidth * 2 + (pngWidth - kWidth * 2 * 2) * prL * 0.5 - (lxL + rxL) / 2 * prL; -//1 pxR = kWidth * 2 + (pngWidth - kWidth * 2 * 2) * prL + kWidth * 2 * 2 + (pngWidth - kWidth * 2 * 2) * prR * 0.5 - (lxR + rxR) / 2 * prR; -//2 pxR = pngWidth * prL + kWidth * 4 + pngWidth * prR * 0.5 - (lxR + rxR) / 2 * prR; -//3 pxL = pngWidth * prL * 0.5 - (lxL + rxL) / 2 * prL; -//3 pxR = pngWidth * prL + pngWidth * prR * 0.5 - (lxR + rxR) / 2 * prR; - pxL = 0; - pxR = pngWidth * prL; + pxL = 0; + pxR = pngWidth * prL; - DoDrawMixFont(parts1, pxL, prL, parts3, pxR, prR, pyL, pryL, pyR, pryR); + DoDrawMixFont(parts1, pxL, prL, parts3, pxR, prR, pyL, pryL, pyR, pryR); //count dots for check crossing over DotsHeight(&chk_y1, &chk_y2); @@ -162,42 +152,40 @@ void combineYoko2(const KGString *parts1, const KGString *parts3, int *result){ } } l = k; - //fprintf(stderr,"%d,%d\n",chk_y1,chk_y2); //get close both parts h = pxR; while(k - l < kMixdot && g < kWidth * 2 * kKasane * 2){ g = g + 2; f = pxR - g; - DoDrawMixFont(parts1, pxL, prL, parts3, f, prR, pyL, pryL, pyR, pryR); - + DoDrawMixFont(parts1, pxL, prL, parts3, f, prR, pyL, pryL, pyR, pryR); + + //FOR DEBUG //char fn[256]; //FILE *fp; //snprintf(fn,sizeof(fn),"%03d.png",g); - //fp = fopen(fn, "w"); - //writePng(pngWidth, pngHeight, kageCanvas, fp); - //fclose(fp); + //fp = fopen(fn, "w"); + //writePng(pngWidth, pngHeight, kageCanvas, fp); + //fclose(fp); - l = 0; - for(i = 0; i < pngWidth * 1.1; i++){ + l = 0; + for(i = 0; i < pngWidth * 1.1; i++){ for(j = chk_y1; j <= chk_y2; j++){ - if(kageCanvas[j][i] == 0) l++; - } - } - } - //fprintf(stderr,"%d:%d:%d\n",g,k,l); - pxR = f; - //if(flg_boxR % 256 / 128 != 0) pxR = pxR + kWidth * 2 * kKasane * 10 / 2; - //if(flg_boxR % 64 / 32 != 0) pxR = pxR + kWidth * 2 * kKasane * 8 / 2; - //else if(k - l > pngWidth * 0.4){ - // if(kShotai == kMincho) pxR = pxR + kMinWidthT * 2 * kKasane * 8 / 2; - // else if(kShotai == kGothic) pxR = pxR + kWidth * 2 * kKasane * 8 / 2; - //} - if((flg_boxL % 2 / 1 != 0) && (flg_boxR % 4 / 2 != 0)){ - if(kShotai == kMincho) pxR = pxR + kMinWidthT * 2 * kKasane * 6 / 2; - else pxR = pxR + kWidth * 2 * kKasane * 6 / 2; - } - else pxR = pxR + kWidth * 2 * kKasane * 2 / 2; + if(kageCanvas[j][i] == 0) l++; + } + } + } + pxR = f; + + if(flg_boxL & FLAG_FLAT_RIGHT && flg_boxR & FLAG_FLAT_LEFT){ + if(kShotai == kMincho){ + pxR = pxR + kMinWidthT * 2 * kKasane * 3 / 2; + } else { + pxR = pxR + kWidth * 2 * kKasane * 3 / 2; + } + } else { + pxR = pxR + kWidth * 2 * kKasane * 2 / 2; + } //set results result[0] = pxL; @@ -213,47 +201,85 @@ void combineYoko2(const KGString *parts1, const KGString *parts3, int *result){ } void combineYoko3(const KGString *parts1, const KGString *parts2, const KGString *parts3, int *result){ - //not yet + //temp. + KGString *tempString; + int tempResult[8], tempResult2[4]; + int minx, miny, maxx, maxy, width, height, width2, height2; + + tempString = kg_string_new(""); + combineYoko2(parts2, parts3, result); + addStrokeWithTransform(parts2, 1, result, tempString, 1); + addStrokeWithTransform(parts3, 3, result, tempString, 1); + tempResult[0] = result[0]; + tempResult[1] = result[1]; + tempResult[2] = result[2]; + tempResult[3] = result[3]; + tempResult[4] = result[8]; + tempResult[5] = result[9]; + tempResult[6] = result[10]; + tempResult[7] = result[11]; + minx = result[0]; + miny = min(result[1], result[9]); + maxx = result[10]; + maxy = max(result[3], result[11]); + width = maxx - minx; + height = maxy - miny; + + combineYoko2(parts1, tempString, result); + tempResult2[0] = result[8]; + tempResult2[1] = result[9]; + tempResult2[2] = result[10]; + tempResult2[3] = result[11]; + width2 = result[10] - result[8]; + height2 = result[11] - result[9]; + + result[4] = tempResult2[0] + (tempResult[0] - minx) * ((double)width2 / width); // always 0 + result[5] = tempResult2[1] + (tempResult[1] - miny) * ((double)height2 / height); + result[6] = tempResult2[0] + (tempResult[2] - minx) * ((double)width2 / width); + result[7] = tempResult2[1] + (tempResult[3] - miny) * ((double)height2 / height); + result[8] = tempResult2[0] + (tempResult[4] - minx) * ((double)width2 / width); + result[9] = tempResult2[1] + (tempResult[5] - miny) * ((double)height2 / height); + result[10] = tempResult2[0] + (tempResult[6] - minx) * ((double)width2 / width); + result[11] = tempResult2[1] + (tempResult[7] - miny) * ((double)height2 / height); } void combineTate2(const KGString *parts1, const KGString *parts3, int *result){ - int f, g, h, i, j, k, l; - int flg_boxL, flg_boxR; - int pxL, pxR, pyL, pyR; - double prL, prR, pryL, pryR, rL, rR, rTemp; - int lxL, rxL, lxR, rxR; - int lyL, ryL, lyR, ryR; - int dlxL, drxL, dlxR, drxR; - int chk_x1, chk_x2; - int mitsuL, mitsuR; - double yokoL, tateL, yokoR, tateR; - int *buf, strokes; + int f, g, h, i, j, k, l; + int flg_boxL, flg_boxR; + int pxL, pxR, pyL, pyR; + double prL, prR, pryL, pryR, rL, rR, rTemp; + int lxL, rxL, lxR, rxR; + int lyL, ryL, lyR, ryR; + int dlxL, drxL, dlxR, drxR; + int chk_x1, chk_x2; + int mitsuL, mitsuR; + double yokoL, tateL, yokoR, tateR; int tempShotai; //initialize - pxL = 0; - pyL = 0; - prL = 1.0; - pryL = 1.0; - pxR = 0; - pyR = 0; - prR = 1.0; - pryR = 1.0; + pxL = 0; + pyL = 0; + prL = 1.0; + pryL = 1.0; + pxR = 0; + pyR = 0; + prR = 1.0; + pryR = 1.0; tempShotai = kShotai; kShotai = kGothic; - CalcOptions(parts1, &mitsuL, &flg_boxL, &yokoL, &tateL); - CalcOptions(parts3, &mitsuR, &flg_boxR, &yokoR, &tateR); + CalcOptions(parts1, &mitsuL, &flg_boxL, &yokoL, &tateL); + CalcOptions(parts3, &mitsuR, &flg_boxR, &yokoR, &tateR); //calculate ratio rL = tateL; rR = tateR; - if(flg_boxL % 8 / 4 != 0) rL = rL * 0.7; - if(flg_boxL % 16 / 8 != 0) rL = rL * 0.7; - if(flg_boxR % 8 / 4 != 0) rR = rR * 0.7; - if(flg_boxR % 16 / 8 != 0) rR = rR * 0.7; + if(flg_boxL & FLAG_FLAT_TOP) rL = rL * 0.7; + if(flg_boxL & FLAG_FLAT_BOTTOM) rL = rL * 0.7; + if(flg_boxR & FLAG_FLAT_TOP) rR = rR * 0.7; + if(flg_boxR & FLAG_FLAT_BOTTOM) rR = rR * 0.7; rL = pow(rL, 0.8); rR = pow(rR, 0.8); @@ -263,83 +289,42 @@ void combineTate2(const KGString *parts1, const KGString *parts3, int *result){ rTemp = rL + rR; rL = rL / rTemp; rR = rR / rTemp; - -// if(r < 0.3) r = 0.3; -// else if(r > 0.7) r = 0.7; - - pryL = rL; - pryR = rR; + + pryL = rL; + pryR = rR; //calucurate size of X-axis - PartsWidth(parts1, &lxL, &rxL); - PartsWidth(parts3, &lxR, &rxR); - PartsHeight(parts1, &lyL, &ryL); - PartsHeight(parts3, &lyR, &ryR); + PartsWidth(parts1, &lxL, &rxL); + PartsWidth(parts3, &lxR, &rxR); + PartsHeight(parts1, &lyL, &ryL); + PartsHeight(parts3, &lyR, &ryR); //left parts - if(flg_boxL % 64 / 32 != 0){ - buf = convertStroke(parts1->str, buf, &strokes); - for(i = 0; i < strokes; i++){ - if(buf[i * 11 + 0] == 0) j = buf[i * 11 + 4]; // center line - } - k = max(j - lxL, rxL - j);// k : distance from center line - prL = (kSize * 0.9 * 0.5) / k; - if(k == j - lxL) pxL = 0; - else pxL = kSize * 0.5 - j * prL; - } - else if(flg_boxL % 2 / 1 != 0 && flg_boxL % 4 / 2 != 0 && flg_boxL % 32 / 16 == 0){ - prL = min(1.0, (double)yokoL * 0.1 + 0.5) - ((kWidth * 6) / (kSize * 0.9)); - DoDrawParts(parts1, pxL, prL, pyL, pryL); - DotsWidth(&dlxL, &drxL); - pxL = (kSize / 2 - (dlxL + drxL) / 2); - } - else if(flg_boxL % 128 / 64 != 0){ - prL = 0.77; - DoDrawParts(parts1, pxL, prL, pyL, pryL); - DotsWidth(&dlxL, &drxL); - pxL = (kSize / 2 - (dlxL + drxL) / 2); - } - else if(flg_boxL % 2 / 1 != 0 && flg_boxL % 32 / 16 == 0){ - prL = (kSize * 0.9 - kWidth * 4) / (rxL - lxL); + if(flg_boxL & FLAG_FLAT_LEFT && flg_boxL & FLAG_FLAT_RIGHT){ + prL = min(1.0, (double)yokoL * 0.1 + 0.5) - ((kWidth * 6) / (kSize * 0.9)); + DoDrawParts(parts1, pxL, prL, pyL, pryL); + DotsWidth(&dlxL, &drxL); + pxL = (kSize / 2 - (dlxL + drxL) / 2); + } else if(flg_boxL & FLAG_FLAT_LEFT){ + prL = (kSize * 0.9 - kWidth * 4) / (rxL - lxL); pxL = kWidth * 4; - } - else if(flg_boxL % 4 / 2 != 0 && flg_boxL % 32 / 16 == 0){ - prL = (kSize * 0.9 - kWidth * 4) / (rxL - lxL); - pxL = (kSize*0.05+kWidth*2) - lxL * prL; - } + } else if(flg_boxL & FLAG_FLAT_RIGHT){ + prL = (kSize * 0.9 - kWidth * 4) / (rxL - lxL); + pxL = (kSize * 0.05 + kWidth * 2) - lxL * prL; + } //right parts - if(flg_boxR % 64 / 32 != 0){ - buf = convertStroke(parts3->str, buf, &strokes); - for(i = 0; i < strokes; i++){ - if(buf[i * 11 + 0] == 0) j = buf[i * 11 + 4]; // center line - } - k = max(j - lxR, rxR - j);// k : distance from center line - prR = (kSize * 0.9 * 0.5) / k; - if(k == j - lxR) pxR = 0; - else pxR = kSize * 0.5 - j * prR; - } - else if(flg_boxR % 2 / 1 != 0 && flg_boxR % 4 / 2 != 0 && flg_boxR % 32 / 16 == 0){ + if(flg_boxR & FLAG_FLAT_LEFT && flg_boxR & FLAG_FLAT_RIGHT){ prR = min(1.0, (double)yokoR * 0.1 + 0.5) - ((kWidth * 6) / (kSize * 0.9)); DoDrawParts(parts3, pxR, prR, pyR, pryR); DotsWidth(&dlxR, &drxR); pxR = (kSize / 2 - (dlxR + drxR) / 2); - } - else if(flg_boxR % 128 / 64 != 0){ - prR = 0.77; - DoDrawParts(parts3, pxR, prR, pyR, pryR); - DotsWidth(&dlxR, &drxR); - pxR = (kSize / 2 - (dlxR + drxR) / 2); - } - else if(flg_boxR % 2 / 1 != 0 && flg_boxR % 32 / 16 == 0){ + } else if(flg_boxR & FLAG_FLAT_LEFT){ prR = (kSize * 0.9 - kWidth * 4) / (rxR - lxR); -// pxR = width * 4; - pxR = (kSize*0.05+kWidth*3) - lxR * prR; - } - else if(flg_boxR % 4 / 2 != 0 && flg_boxR % 32 / 16 == 0){ + pxR = (kSize * 0.05 + kWidth * 3) - lxR * prR; + } else if(flg_boxR & FLAG_FLAT_RIGHT){ prR = (kSize * 0.9 - kWidth * 4) / (rxR - lxR); -// pxR = (size*0.05+width*2) - lxR * prR; - pxR = (kSize*0.05+kWidth*1) - lxR * prR; + pxR = (kSize * 0.05 + kWidth * 1) - lxR * prR; } g = 0; @@ -365,18 +350,21 @@ void combineTate2(const KGString *parts1, const KGString *parts3, int *result){ while(k - l < kMixdot && g < kWidth * (kKasane + 4)){ g = g + 2; f = pyR - g; - DoDrawMixFont(parts1, pxL, prL, parts3, pxR, prR, pyL, pryL, f, pryR); + DoDrawMixFont(parts1, pxL, prL, parts3, pxR, prR, pyL, pryL, f, pryR); - l = 0; - for(i = 0; i < pngWidth * 1.1; i++){ - for(j = chk_x1; j <= chk_x2; j++){ - if(kageCanvas[i][j] == 0) l++; - } - } - } - pyR = f; - if(k - l > pngWidth * 0.4) pyR = pyR + kWidth * 5; - else pyR = pyR + kWidth * 3; + l = 0; + for(i = 0; i < pngWidth * 1.1; i++){ + for(j = chk_x1; j <= chk_x2; j++){ + if(kageCanvas[i][j] == 0) l++; + } + } + } + pyR = f; + if(k - l > pngWidth * 0.4){ + pyR = pyR + kWidth * 4; + } else { + pyR = pyR + kWidth * 2; + } //set results result[0] = pxL; @@ -392,35 +380,81 @@ void combineTate2(const KGString *parts1, const KGString *parts3, int *result){ } void combineTate3(const KGString *parts1, const KGString *parts2, const KGString *parts3, int *result){ - //not yet + //temp. + //temp. + KGString *tempString; + int tempResult[8], tempResult2[4]; + int minx, miny, maxx, maxy, width, height, width2, height2; + + tempString = kg_string_new(""); + combineTate2(parts2, parts3, result); + addStrokeWithTransform(parts2, 1, result, tempString, 1); + addStrokeWithTransform(parts3, 3, result, tempString, 1); + tempResult[0] = result[0]; + tempResult[1] = result[1]; + tempResult[2] = result[2]; + tempResult[3] = result[3]; + tempResult[4] = result[8]; + tempResult[5] = result[9]; + tempResult[6] = result[10]; + tempResult[7] = result[11]; + minx = min(result[0], result[8]); + miny = min(result[1], result[9]); + maxx = max(result[2], result[10]); + maxy = max(result[3], result[11]); + width = maxx - minx; + height = maxy - miny; + + combineTate2(parts1, tempString, result); + tempResult2[0] = result[8]; + tempResult2[1] = result[9]; + tempResult2[2] = result[10]; + tempResult2[3] = result[11]; + width2 = result[10] - result[8]; + height2 = result[11] - result[9]; + + result[4] = tempResult2[0] + (tempResult[0] - minx) * ((double)width2 / width); // always 0 + result[5] = tempResult2[1] + (tempResult[1] - miny) * ((double)height2 / height); + result[6] = tempResult2[0] + (tempResult[2] - minx) * ((double)width2 / width); + result[7] = tempResult2[1] + (tempResult[3] - miny) * ((double)height2 / height); + result[8] = tempResult2[0] + (tempResult[4] - minx) * ((double)width2 / width); + result[9] = tempResult2[1] + (tempResult[5] - miny) * ((double)height2 / height); + result[10] = tempResult2[0] + (tempResult[6] - minx) * ((double)width2 / width); + result[11] = tempResult2[1] + (tempResult[7] - miny) * ((double)height2 / height); } void combineHame2(const KGString *parts1, const KGString *parts3, int *result){ - int i, flag; - int *buf, strokes; - - flag = 0; - - //set results - result[0] = 0; - result[1] = 0; - result[2] = 200; - result[3] = 200; - buf = convertStroke(parts1->str, buf, &strokes); - for(i = 0; i < strokes; i++){ - if(buf[i * 11 + 0] == 9){ - result[8] = buf[i * 11 + 3]; - result[9] = buf[i * 11 + 4]; - result[10] = buf[i * 11 + 5]; - result[11] = buf[i * 11 + 6]; - flag = 1; - } - } - if(flag == 0){ //error - result[8] = 50; - result[9] = 50; - result[10] = 150; - result[11] = 150; - } - //not yet + int i, flag; + int *buf, strokes; + double yoko, tate; + int mitsu, flg_box; + + flag = 0; + CalcOptions(parts3, &mitsu, &flg_box, &yoko, &tate); + + //set results + result[0] = 0; + result[1] = 0; + result[2] = 200; + result[3] = 200; + buf = convertStroke(parts1->str, buf, &strokes); + for(i = 0; i < strokes; i++){ + if(buf[i * 11 + 0] == 9){ + result[8] = buf[i * 11 + 3]; + if(flg_box & FLAG_FLAT_LEFT) result[8] += kWidth * 4; + result[9] = buf[i * 11 + 4]; + if(flg_box & FLAG_FLAT_TOP) result[9] += kWidth * 4; + result[10] = buf[i * 11 + 5]; + if(flg_box & FLAG_FLAT_RIGHT) result[10] -= kWidth * 4; + result[11] = buf[i * 11 + 6]; + if(flg_box & FLAG_FLAT_BOTTOM) result[11] -= kWidth * 4; + flag = 1; + } + } + if(flag == 0){ //error + result[8] = 50; + result[9] = 50; + result[10] = 150; + result[11] = 150; + } }