MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / PiuStyleCreate

Function PiuStyleCreate

modules/piu/All/piuStyle.c:144–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144void PiuStyleCreate(xsMachine* the)
145{
146 xsIntegerValue c = xsToInteger(xsArgc);
147 PiuStyleRecord record;
148 PiuStyle self = &record;
149 xsStringValue string;
150 xsIntegerValue integer;
151 char buffer[256] = "";
152 xsVars(1); // PiuColorsDictionary
153 c_memset(self, 0, sizeof(record));
154 self->reference = xsToReference(xsThis);
155 self->the = the;
156 self->color[0].a = 255;
157 self->color[1].a = 255;
158 self->color[2].a = 255;
159 self->color[3].a = 255;
160 if ((c > 0) && (xsTest(xsArg(0)))) {
161 if (xsFindResult(xsArg(0), xsID_archive))
162 self->archive = xsToReference(xsResult);
163 if (xsFindString(xsArg(0), xsID_font, &string)) {
164 const PiuStyleBuilder* builder;
165 xsStringValue p = string;
166 xsStringValue q;
167 char c;
168 char state = 0;
169 for (;;) {
170 while ((c = c_read8(p))) {
171 if (c != ' ')
172 break;
173 p++;
174 }
175 q = p;
176 while ((c = c_read8(q))) {
177 if (c == ' ')
178 break;
179 q++;
180 }
181 if (p == q)
182 break;
183 if ((state == 0) && (c_strncmp(p, "inherit", q - p))) {
184 if (!c_strncmp(p, "italic", q - p))
185 self->flags |= piuStyleItalic | piuStyleItalicBit;
186 else if (!c_strncmp(p, "normal", q - p))
187 self->flags |= piuStyleItalic;
188 else
189 state = 1;
190 }
191 if ((state == 1) && (c_strncmp(p, "inherit", q - p))) {
192 for (builder = piuStyleWeightBuilders; builder->name; builder++) {
193 if (!c_strncmp(p, builder->name, q - p)) {
194 self->weight = (int8_t)builder->value;
195 self->flags |= builder->flags;
196 break;
197 }
198 }
199 if (!builder->name)
200 state = 2;
201 }

Callers

nothing calls this directly

Calls 1

PiuColorsDictionaryFunction · 0.85

Tested by

no test coverage detected